Lines Matching refs:pIdx
1092 i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){ in sqlite3TableColumnToIndex() argument
1094 for(i=0; i<pIdx->nColumn; i++){ in sqlite3TableColumnToIndex()
1095 if( iCol==pIdx->aiColumn[i] ) return i; in sqlite3TableColumnToIndex()
1619 Index *pIdx; in sqlite3AddNotNull() local
1620 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ in sqlite3AddNotNull()
1621 assert( pIdx->nKeyCol==1 && pIdx->onError!=OE_None ); in sqlite3AddNotNull()
1622 if( pIdx->aiColumn[0]==p->nCol-1 ){ in sqlite3AddNotNull()
1623 pIdx->uniqNotNull = 1; in sqlite3AddNotNull()
1955 Index *pIdx; in sqlite3AddCollateType() local
1962 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ in sqlite3AddCollateType()
1963 assert( pIdx->nKeyCol==1 ); in sqlite3AddCollateType()
1964 if( pIdx->aiColumn[0]==i ){ in sqlite3AddCollateType()
1965 pIdx->azColl[0] = sqlite3ColumnColl(&p->aCol[i]); in sqlite3AddCollateType()
2080 static void identPut(char *z, int *pIdx, char *zSignedIdent){ in identPut() argument
2083 i = *pIdx; in identPut()
2100 *pIdx = i; in identPut()
2176 static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){ in resizeIndexObject() argument
2179 if( pIdx->nColumn>=N ) return SQLITE_OK; in resizeIndexObject()
2180 assert( pIdx->isResized==0 ); in resizeIndexObject()
2184 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn); in resizeIndexObject()
2185 pIdx->azColl = (const char**)zExtra; in resizeIndexObject()
2187 memcpy(zExtra, pIdx->aiRowLogEst, sizeof(LogEst)*(pIdx->nKeyCol+1)); in resizeIndexObject()
2188 pIdx->aiRowLogEst = (LogEst*)zExtra; in resizeIndexObject()
2190 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn); in resizeIndexObject()
2191 pIdx->aiColumn = (i16*)zExtra; in resizeIndexObject()
2193 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn); in resizeIndexObject()
2194 pIdx->aSortOrder = (u8*)zExtra; in resizeIndexObject()
2195 pIdx->nColumn = N; in resizeIndexObject()
2196 pIdx->isResized = 1; in resizeIndexObject()
2217 static void estimateIndexWidth(Index *pIdx){ in estimateIndexWidth() argument
2220 const Column *aCol = pIdx->pTable->aCol; in estimateIndexWidth()
2221 for(i=0; i<pIdx->nColumn; i++){ in estimateIndexWidth()
2222 i16 x = pIdx->aiColumn[i]; in estimateIndexWidth()
2223 assert( x<pIdx->pTable->nCol ); in estimateIndexWidth()
2224 wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst; in estimateIndexWidth()
2226 pIdx->szIdxRow = sqlite3LogEst(wIndex*4); in estimateIndexWidth()
2255 static int isDupColumn(Index *pIdx, int nKey, Index *pPk, int iCol){ in isDupColumn() argument
2257 assert( nKey<=pIdx->nColumn ); in isDupColumn()
2261 assert( pPk->pTable==pIdx->pTable ); in isDupColumn()
2262 testcase( pPk==pIdx ); in isDupColumn()
2266 assert( pIdx->aiColumn[i]>=0 || j>=0 ); in isDupColumn()
2267 if( pIdx->aiColumn[i]==j in isDupColumn()
2268 && sqlite3StrICmp(pIdx->azColl[i], pPk->azColl[iCol])==0 in isDupColumn()
2295 static void recomputeColumnsNotIndexed(Index *pIdx){ in recomputeColumnsNotIndexed() argument
2298 Table *pTab = pIdx->pTable; in recomputeColumnsNotIndexed()
2299 for(j=pIdx->nColumn-1; j>=0; j--){ in recomputeColumnsNotIndexed()
2300 int x = pIdx->aiColumn[j]; in recomputeColumnsNotIndexed()
2307 pIdx->colNotIdxed = ~m; in recomputeColumnsNotIndexed()
2308 assert( (pIdx->colNotIdxed>>63)==1 ); /* See note-20221022-a */ in recomputeColumnsNotIndexed()
2336 Index *pIdx; in convertToWithoutRowidTable() local
2435 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ in convertToWithoutRowidTable()
2437 if( IsPrimaryKeyIndex(pIdx) ) continue; in convertToWithoutRowidTable()
2439 if( !isDupColumn(pIdx, pIdx->nKeyCol, pPk, i) ){ in convertToWithoutRowidTable()
2440 testcase( hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ); in convertToWithoutRowidTable()
2446 pIdx->nColumn = pIdx->nKeyCol; in convertToWithoutRowidTable()
2449 if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return; in convertToWithoutRowidTable()
2450 for(i=0, j=pIdx->nKeyCol; i<nPk; i++){ in convertToWithoutRowidTable()
2451 if( !isDupColumn(pIdx, pIdx->nKeyCol, pPk, i) ){ in convertToWithoutRowidTable()
2452 testcase( hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ); in convertToWithoutRowidTable()
2453 pIdx->aiColumn[j] = pPk->aiColumn[i]; in convertToWithoutRowidTable()
2454 pIdx->azColl[j] = pPk->azColl[i]; in convertToWithoutRowidTable()
2457 pIdx->bAscKeyBug = 1; in convertToWithoutRowidTable()
2462 assert( pIdx->nColumn>=pIdx->nKeyCol+n ); in convertToWithoutRowidTable()
2463 assert( pIdx->nColumn>=j ); in convertToWithoutRowidTable()
2625 Index *pIdx; /* An implied index of the table */ in sqlite3EndTable() local
2763 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ in sqlite3EndTable()
2764 estimateIndexWidth(pIdx); in sqlite3EndTable()
3234 Index *pIdx = sqliteHashData(pElem); in sqlite3RootPageMoved() local
3235 if( pIdx->tnum==iFrom ){ in sqlite3RootPageMoved()
3236 pIdx->tnum = iTo; in sqlite3RootPageMoved()
3299 Index *pIdx; in destroyTable() local
3305 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ in destroyTable()
3306 Pgno iIdx = pIdx->tnum; in destroyTable()
3307 assert( pIdx->pSchema==pTab->pSchema ); in destroyTable()
4299 Index *pIdx; in sqlite3CreateIndex() local
4300 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ in sqlite3CreateIndex()
4302 assert( IsUniqueIndex(pIdx) ); in sqlite3CreateIndex()
4303 assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF ); in sqlite3CreateIndex()
4306 if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue; in sqlite3CreateIndex()
4307 for(k=0; k<pIdx->nKeyCol; k++){ in sqlite3CreateIndex()
4310 assert( pIdx->aiColumn[k]>=0 ); in sqlite3CreateIndex()
4311 if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break; in sqlite3CreateIndex()
4312 z1 = pIdx->azColl[k]; in sqlite3CreateIndex()
4316 if( k==pIdx->nKeyCol ){ in sqlite3CreateIndex()
4317 if( pIdx->onError!=pIndex->onError ){ in sqlite3CreateIndex()
4325 if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){ in sqlite3CreateIndex()
4329 if( pIdx->onError==OE_Default ){ in sqlite3CreateIndex()
4330 pIdx->onError = pIndex->onError; in sqlite3CreateIndex()
4333 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType; in sqlite3CreateIndex()
4513 void sqlite3DefaultRowEst(Index *pIdx){ in sqlite3DefaultRowEst() argument
4516 LogEst *a = pIdx->aiRowLogEst; in sqlite3DefaultRowEst()
4518 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol); in sqlite3DefaultRowEst()
4522 assert( !pIdx->hasStat1 ); in sqlite3DefaultRowEst()
4534 x = pIdx->pTable->nRowLogEst; in sqlite3DefaultRowEst()
4537 pIdx->pTable->nRowLogEst = x = 99; in sqlite3DefaultRowEst()
4539 if( pIdx->pPartIdxWhere!=0 ){ x -= 10; assert( 10==sqlite3LogEst(2) ); } in sqlite3DefaultRowEst()
4545 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){ in sqlite3DefaultRowEst()
4550 if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0; in sqlite3DefaultRowEst()
4644 int *pIdx /* Write the index of a new slot here */ in sqlite3ArrayAllocate() argument
4647 sqlite3_int64 n = *pIdx = *pnEntry; in sqlite3ArrayAllocate()
4652 *pIdx = -1; in sqlite3ArrayAllocate()
5339 Index *pIdx /* The index that triggers the constraint */ in sqlite3UniqueConstraint() argument
5344 Table *pTab = pIdx->pTable; in sqlite3UniqueConstraint()
5348 if( pIdx->aColExpr ){ in sqlite3UniqueConstraint()
5349 sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName); in sqlite3UniqueConstraint()
5351 for(j=0; j<pIdx->nKeyCol; j++){ in sqlite3UniqueConstraint()
5353 assert( pIdx->aiColumn[j]>=0 ); in sqlite3UniqueConstraint()
5354 zCol = pTab->aCol[pIdx->aiColumn[j]].zCnName; in sqlite3UniqueConstraint()
5363 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY in sqlite3UniqueConstraint()
5528 KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){ in sqlite3KeyInfoOfIndex() argument
5530 int nCol = pIdx->nColumn; in sqlite3KeyInfoOfIndex()
5531 int nKey = pIdx->nKeyCol; in sqlite3KeyInfoOfIndex()
5534 if( pIdx->uniqNotNull ){ in sqlite3KeyInfoOfIndex()
5542 const char *zColl = pIdx->azColl[i]; in sqlite3KeyInfoOfIndex()
5545 pKey->aSortFlags[i] = pIdx->aSortOrder[i]; in sqlite3KeyInfoOfIndex()
5550 if( pIdx->bNoQuery==0 ){ in sqlite3KeyInfoOfIndex()
5558 pIdx->bNoQuery = 1; in sqlite3KeyInfoOfIndex()