Lines Matching refs:pIter

9202 int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
9231 sqlite3_changeset_iter *pIter, /* Iterator object */
9264 sqlite3_changeset_iter *pIter, /* Iterator object */
9294 sqlite3_changeset_iter *pIter, /* Changeset iterator */
9327 sqlite3_changeset_iter *pIter, /* Changeset iterator */
9354 sqlite3_changeset_iter *pIter, /* Changeset iterator */
9370 sqlite3_changeset_iter *pIter, /* Changeset iterator */
9402 int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);
55410 WalIterator *pIter = 0; /* Wal iterator context */
55425 rc = walIteratorInit(pWal, &pIter);
55429 assert( pIter );
55493 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
55573 walIteratorFree(pIter);
58385 BtLock *pIter;
58412 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
58422 assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );
58423 assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);
58424 if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){
58425 sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);
58458 BtLock *pIter;
58476 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
58477 if( pIter->iTable==iTable && pIter->pBtree==p ){
58478 pLock = pIter;
59240 u8 *pIter; /* For scanning through pCell */
59248 pIter = pCell;
59256 nPayload = *pIter;
59258 u8 *pEnd = &pIter[8];
59261 nPayload = (nPayload<<7) | (*++pIter & 0x7f);
59262 }while( (*pIter)>=0x80 && pIter<pEnd );
59264 pIter++;
59272 iKey = *pIter;
59274 u8 *pEnd = &pIter[7];
59277 iKey = (iKey<<7) | (*++pIter & 0x7f);
59278 if( (*pIter)<0x80 ) break;
59279 if( pIter>=pEnd ){
59280 iKey = (iKey<<8) | *++pIter;
59285 pIter++;
59289 pInfo->pPayload = pIter;
59296 pInfo->nSize = nPayload + (u16)(pIter - pCell);
59308 u8 *pIter; /* For scanning through pCell */
59314 pIter = pCell + pPage->childPtrSize;
59315 nPayload = *pIter;
59317 u8 *pEnd = &pIter[8];
59320 nPayload = (nPayload<<7) | (*++pIter & 0x7f);
59321 }while( *(pIter)>=0x80 && pIter<pEnd );
59323 pIter++;
59326 pInfo->pPayload = pIter;
59333 pInfo->nSize = nPayload + (u16)(pIter - pCell);
59361 u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */
59374 nSize = *pIter;
59376 pEnd = &pIter[8];
59379 nSize = (nSize<<7) | (*++pIter & 0x7f);
59380 }while( *(pIter)>=0x80 && pIter<pEnd );
59382 pIter++;
59387 pEnd = &pIter[9];
59388 while( (*pIter++)&0x80 && pIter<pEnd );
59393 nSize += (u32)(pIter - pCell);
59403 nSize += 4 + (u16)(pIter - pCell);
59409 u8 *pIter = pCell + 4; /* For looping over bytes of pCell */
59424 pEnd = pIter + 9;
59425 while( (*pIter++)&0x80 && pIter<pEnd );
59426 assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );
59427 return (u16)(pIter - pCell);
61302 BtLock *pIter;
61303 for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
61304 if( pIter->pBtree!=p ){
61305 pBlock = pIter->pBtree->db;
87519 FileChunk *pIter;
87521 for(pIter=p->pFirst; pIter; pIter=pNext){
87522 pNext = pIter->pNext;
87523 sqlite3_free(pIter);
87541 FileChunk *pIter;
87542 for(pIter=copy.pFirst; pIter; pIter=pIter->pNext){
87546 rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);
146169 char *pIter; /* Used to iterate through aAll */
146173 pIter = pDL->pNextDocid;
146175 pIter = pDL->aAll;
146178 if( pIter>=pEnd ){
146183 pIter += sqlite3Fts3GetVarint(pIter, &iDelta);
146189 pDL->pList = pIter;
146190 fts3PoslistCopy(0, &pIter);
146191 pDL->nList = (int)(pIter - pDL->pList);
146199 while( pIter<pEnd && *pIter==0 ) pIter++;
146201 pDL->pNextDocid = pIter;
146202 assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );
147536 char *pIter;
147549 pIter = pPhrase->doclist.pList;
147601 pIter = pPh->pOrPoslist;
147605 (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll));
147606 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
147609 &pIter, &iDocid, &bEof
147613 bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll);
147614 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
147618 &pIter, &iDocid, &dummy, &bEof
147622 pPh->pOrPoslist = pIter;
147628 pIter = pPhrase->pOrPoslist;
147630 pIter = 0;
147633 if( pIter==0 ) return SQLITE_OK;
147635 if( *pIter==0x01 ){
147636 pIter++;
147637 pIter += fts3GetVarint32(pIter, &iThis);
147642 fts3ColumnlistCopy(0, &pIter);
147643 if( *pIter==0x00 ) return SQLITE_OK;
147644 pIter++;
147645 pIter += fts3GetVarint32(pIter, &iThis);
147647 if( *pIter==0x00 ){
147648 pIter = 0;
147651 *ppOut = ((iCol==iThis)?pIter:0);
148992 Fts3Expr *pIter = pNotBranch;
148993 while( pIter->pLeft ){
148994 pIter = pIter->pLeft;
148996 pIter->pLeft = pRet;
148997 pRet->pParent = pIter;
153984 SegmentNode *pIter;
153987 for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){
153988 int nStart = fts3TreeFinishNode(pIter, iHeight, iNextLeaf);
153989 int nWrite = pIter->nData - nStart;
153991 rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);
153993 iNextLeaf += (pIter->nEntry+1);
157860 char *pIter = *ppIter;
157861 if( pIter ){
157865 if( 0==(*pIter & 0xFE) ){
157867 pIter = 0;
157870 fts3GetDeltaPosition(&pIter, &iIter);
157874 *ppIter = pIter;
157881 static int fts3SnippetNextCandidate(SnippetIter *pIter){
157884 if( pIter->iCurrent<0 ){
157889 pIter->iCurrent = 0;
157894 for(i=0; i<pIter->nPhrase; i++){
157895 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
157896 fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, pIter->nSnippet);
157902 for(i=0; i<pIter->nPhrase; i++){
157903 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
157912 pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;
157913 for(i=0; i<pIter->nPhrase; i++){
157914 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
157928 SnippetIter *pIter, /* Snippet iterator */
157935 int iStart = pIter->iCurrent; /* First token of snippet */
157941 for(i=0; i<pIter->nPhrase; i++){
157942 SnippetPhrase *pPhrase = &pIter->aPhrase[i];
157947 while( iCsr<(iStart+pIter->nSnippet) ){
158377 char *pIter = pPhrase->doclist.pList;
158388 int nHit = fts3ColumnlistCount(&pIter);
158396 assert( *pIter==0x00 || *pIter==0x01 );
158397 if( *pIter!=0x01 ) break;
158398 pIter++;
158399 pIter += fts3GetVarint32(pIter, &iCol);
158602 static int fts3LcsIteratorAdvance(LcsIterator *pIter){
158603 char *pRead = pIter->pRead;
158612 pIter->iPos += (int)(iRead-2);
158615 pIter->pRead = pRead;
158645 LcsIterator *pIter = &aIter[i];
158646 nToken -= pIter->pExpr->pPhrase->nToken;
158647 pIter->iPosOffset = nToken;
158671 LcsIterator *pIter = &aIter[i];
158672 if( pIter->pRead==0 ){
158676 if( pAdv==0 || pIter->iPos<pAdv->iPos ){
158677 pAdv = pIter;
158679 if( nThisLcs==0 || pIter->iPos==pIter[-1].iPos ){
164144 UBreakIterator *pIter; /* ICU break-iterator object */
164257 pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status);
164264 ubrk_first(pCsr->pIter);
164274 ubrk_close(pCsr->pIter);
164300 iStart = ubrk_current(pCsr->pIter);
164301 iEnd = ubrk_next(pCsr->pIter);
165690 static void rbuObjIterFreeCols(RbuObjIter *pIter){
165692 for(i=0; i<pIter->nTblCol; i++){
165693 sqlite3_free(pIter->azTblCol[i]);
165694 sqlite3_free(pIter->azTblType[i]);
165696 sqlite3_free(pIter->azTblCol);
165697 pIter->azTblCol = 0;
165698 pIter->azTblType = 0;
165699 pIter->aiSrcOrder = 0;
165700 pIter->abTblPk = 0;
165701 pIter->abNotNull = 0;
165702 pIter->nTblCol = 0;
165703 pIter->eType = 0; /* Invalid value */
165710 static void rbuObjIterClearStatements(RbuObjIter *pIter){
165713 sqlite3_finalize(pIter->pSelect);
165714 sqlite3_finalize(pIter->pInsert);
165715 sqlite3_finalize(pIter->pDelete);
165716 sqlite3_finalize(pIter->pTmpInsert);
165717 pUp = pIter->pRbuUpdate;
165725 pIter->pSelect = 0;
165726 pIter->pInsert = 0;
165727 pIter->pDelete = 0;
165728 pIter->pRbuUpdate = 0;
165729 pIter->pTmpInsert = 0;
165730 pIter->nCol = 0;
165737 static void rbuObjIterFinalize(RbuObjIter *pIter){
165738 rbuObjIterClearStatements(pIter);
165739 sqlite3_finalize(pIter->pTblIter);
165740 sqlite3_finalize(pIter->pIdxIter);
165741 rbuObjIterFreeCols(pIter);
165742 memset(pIter, 0, sizeof(RbuObjIter));
165753 static int rbuObjIterNext(sqlite3rbu *p, RbuObjIter *pIter){
165758 rbuObjIterClearStatements(pIter);
165759 if( pIter->zIdx==0 ){
165770 if( pIter->bCleanup ){
165771 rbuObjIterFreeCols(pIter);
165772 pIter->bCleanup = 0;
165773 rc = sqlite3_step(pIter->pTblIter);
165775 rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg);
165776 pIter->zTbl = 0;
165778 pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0);
165779 pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1);
165780 rc = (pIter->zDataTbl && pIter->zTbl) ? SQLITE_OK : SQLITE_NOMEM;
165783 if( pIter->zIdx==0 ){
165784 sqlite3_stmt *pIdx = pIter->pIdxIter;
165785 rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);
165788 rc = sqlite3_step(pIter->pIdxIter);
165790 rc = resetAndCollectError(pIter->pIdxIter, &p->zErrmsg);
165791 pIter->bCleanup = 1;
165792 pIter->zIdx = 0;
165794 pIter->zIdx = (const char*)sqlite3_column_text(pIter->pIdxIter, 0);
165795 pIter->iTnum = sqlite3_column_int(pIter->pIdxIter, 1);
165796 pIter->bUnique = sqlite3_column_int(pIter->pIdxIter, 2);
165797 rc = pIter->zIdx ? SQLITE_OK : SQLITE_NOMEM;
165805 rbuObjIterFinalize(pIter);
165868 static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
165870 memset(pIter, 0, sizeof(RbuObjIter));
165872 rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg,
165882 rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,
165889 pIter->bCleanup = 1;
165891 return rbuObjIterNext(p, pIter);
165975 static void rbuAllocateIterArrays(sqlite3rbu *p, RbuObjIter *pIter, int nCol){
165981 pIter->azTblCol = azNew;
165982 pIter->azTblType = &azNew[nCol];
165983 pIter->aiSrcOrder = (int*)&pIter->azTblType[nCol];
165984 pIter->abTblPk = (u8*)&pIter->aiSrcOrder[nCol];
165985 pIter->abNotNull = (u8*)&pIter->abTblPk[nCol];
165986 pIter->abIndexed = (u8*)&pIter->abNotNull[nCol];
166156 static void rbuObjIterCacheIndexedCols(sqlite3rbu *p, RbuObjIter *pIter){
166161 memcpy(pIter->abIndexed, pIter->abTblPk, sizeof(u8)*pIter->nTblCol);
166163 sqlite3_mprintf("PRAGMA main.index_list = %Q", pIter->zTbl)
166167 pIter->nIndex = 0;
166177 if( iCid>=0 ) pIter->abIndexed[iCid] = 1;
166181 pIter->nIndex++;
166184 if( pIter->eType==RBU_PK_WITHOUT_ROWID ){
166186 pIter->nIndex--;
166190 if( bIndex==0 ) pIter->abIndexed = 0;
166203 static int rbuObjIterCacheTableInfo(sqlite3rbu *p, RbuObjIter *pIter){
166204 if( pIter->azTblCol==0 ){
166213 assert( pIter->eType==0 );
166214 rbuTableType(p, pIter->zTbl, &pIter->eType, &iTnum, &pIter->iPkTnum);
166215 if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_NOTABLE ){
166217 p->zErrmsg = sqlite3_mprintf("no such table: %s", pIter->zTbl);
166220 if( pIter->zIdx==0 ) pIter->iTnum = iTnum;
166222 assert( pIter->eType==RBU_PK_NONE || pIter->eType==RBU_PK_IPK
166223 || pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_WITHOUT_ROWID
166224 || pIter->eType==RBU_PK_VTAB
166231 sqlite3_mprintf("SELECT * FROM '%q'", pIter->zDataTbl)
166235 rbuAllocateIterArrays(p, pIter, nCol);
166241 pIter->aiSrcOrder[pIter->nTblCol] = pIter->nTblCol;
166242 pIter->azTblCol[pIter->nTblCol++] = zCopy;
166253 && bRbuRowid!=(pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE)
166257 "table %q %s rbu_rowid column", pIter->zDataTbl,
166267 sqlite3_mprintf("PRAGMA table_info(%Q)", pIter->zTbl)
166273 for(i=iOrder; i<pIter->nTblCol; i++){
166274 if( 0==strcmp(zName, pIter->azTblCol[i]) ) break;
166276 if( i==pIter->nTblCol ){
166279 pIter->zDataTbl, zName
166287 SWAP(int, pIter->aiSrcOrder[i], pIter->aiSrcOrder[iOrder]);
166288 SWAP(char*, pIter->azTblCol[i], pIter->azTblCol[iOrder]);
166291 pIter->azTblType[iOrder] = rbuStrndup(zType, &p->rc);
166292 pIter->abTblPk[iOrder] = (iPk!=0);
166293 pIter->abNotNull[iOrder] = (u8)bNotNull || (iPk!=0);
166299 rbuObjIterCacheIndexedCols(p, pIter);
166300 assert( pIter->eType!=RBU_PK_VTAB || pIter->abIndexed==0 );
166301 assert( pIter->eType!=RBU_PK_VTAB || pIter->nIndex==0 );
166314 RbuObjIter *pIter /* Object iterator for column names */
166319 for(i=0; i<pIter->nTblCol; i++){
166320 const char *z = pIter->azTblCol[i];
166353 RbuObjIter *pIter, /* Object iterator for column names */
166373 sqlite3_mprintf("PRAGMA main.index_xinfo = %Q", pIter->zIdx)
166387 if( pIter->eType==RBU_PK_IPK ){
166389 for(i=0; pIter->abTblPk[i]==0; i++);
166390 assert( i<pIter->nTblCol );
166391 zCol = pIter->azTblCol[i];
166399 zCol = pIter->azTblCol[iCid];
166400 zType = pIter->azTblType[iCid];
166404 if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){
166457 RbuObjIter *pIter,
166461 if( p->rc==SQLITE_OK && pIter->abIndexed ){
166464 for(i=0; i<pIter->nTblCol; i++){
166465 if( pIter->abIndexed[i] ){
166466 const char *zCol = pIter->azTblCol[i];
166479 if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){
166498 RbuObjIter *pIter
166501 if( pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE ){
166502 zList = rbuMPrintf(p, "_rowid_ = ?%d", pIter->nTblCol+1);
166503 }else if( pIter->eType==RBU_PK_EXTERNAL ){
166506 for(i=0; i<pIter->nTblCol; i++){
166507 if( pIter->abTblPk[i] ){
166519 for(i=0; i<pIter->nTblCol; i++){
166520 if( pIter->abTblPk[i] ){
166521 const char *zCol = pIter->azTblCol[i];
166562 RbuObjIter *pIter,
166569 if( (int)strlen(zMask)!=pIter->nTblCol ){
166573 for(i=0; i<pIter->nTblCol; i++){
166574 char c = zMask[pIter->aiSrcOrder[i]];
166577 zList, zSep, pIter->azTblCol[i], i+1
166583 zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1
166589 zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1
166641 static char *rbuWithoutRowidPK(sqlite3rbu *p, RbuObjIter *pIter){
166643 assert( pIter->zIdx==0 );
166650 sqlite3_mprintf("PRAGMA main.index_list = %Q", pIter->zTbl)
166700 static void rbuCreateImposterTable2(sqlite3rbu *p, RbuObjIter *pIter){
166701 if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_EXTERNAL ){
166702 int tnum = pIter->iPkTnum; /* Root page of PK index */
166736 iCid, pIter->azTblType[iCid], zCollate
166774 static void rbuCreateImposterTable(sqlite3rbu *p, RbuObjIter *pIter){
166775 if( p->rc==SQLITE_OK && pIter->eType!=RBU_PK_VTAB ){
166776 int tnum = pIter->iTnum;
166782 for(iCol=0; p->rc==SQLITE_OK && iCol<pIter->nTblCol; iCol++){
166784 const char *zCol = pIter->azTblCol[iCol];
166788 p->dbMain, "main", pIter->zTbl, zCol, 0, &zColl, 0, 0, 0
166791 if( pIter->eType==RBU_PK_IPK && pIter->abTblPk[iCol] ){
166797 zSql, zComma, zCol, pIter->azTblType[iCol], zPk, zColl,
166798 (pIter->abNotNull[iCol] ? " NOT NULL" : "")
166803 if( pIter->eType==RBU_PK_WITHOUT_ROWID ){
166804 char *zPk = rbuWithoutRowidPK(p, pIter);
166812 pIter->zTbl, zSql,
166813 (pIter->eType==RBU_PK_WITHOUT_ROWID ? " WITHOUT ROWID" : "")
166832 RbuObjIter *pIter,
166836 int bRbuRowid = (pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE);
166837 char *zBind = rbuObjIterGetBindlist(p, pIter->nTblCol + 1 + bRbuRowid);
166839 assert( pIter->pTmpInsert==0 );
166841 p->dbRbu, &pIter->pTmpInsert, &p->zErrmsg, sqlite3_mprintf(
166843 p->zStateDb, pIter->zDataTbl, zCollist, zRbuRowid, zBind
166885 RbuObjIter *pIter,
166888 assert( pIter->bCleanup==0 );
166889 if( pIter->pSelect==0 && rbuObjIterCacheTableInfo(p, pIter)==SQLITE_OK ){
166890 const int tnum = pIter->iTnum;
166893 const char *zIdx = pIter->zIdx;
166902 const char *zTbl = pIter->zTbl;
166909 assert( pIter->eType!=RBU_PK_VTAB );
166911 p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind
166925 pIter->nCol = nBind;
166928 p->dbMain, &pIter->pInsert, &p->zErrmsg,
166936 p->dbMain, &pIter->pDelete, &p->zErrmsg,
166948 pIter->zDataTbl,
166953 if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){
166956 zCollist, p->zStateDb, pIter->zDataTbl,
166966 zCollist, p->zStateDb, pIter->zDataTbl,
166967 zCollist, pIter->zDataTbl,
166971 p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, zSql);
166979 int bRbuRowid = (pIter->eType==RBU_PK_VTAB)
166980 ||(pIter->eType==RBU_PK_NONE)
166981 ||(pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p));
166982 const char *zTbl = pIter->zTbl; /* Table this step applies to */
166985 char *zBindings = rbuObjIterGetBindlist(p, pIter->nTblCol + bRbuRowid);
166986 char *zWhere = rbuObjIterGetWhere(p, pIter);
166987 char *zOldlist = rbuObjIterGetOldlist(p, pIter, "old");
166988 char *zNewlist = rbuObjIterGetOldlist(p, pIter, "new");
166990 zCollist = rbuObjIterGetCollist(p, pIter);
166991 pIter->nCol = pIter->nTblCol;
166994 rbuCreateImposterTable(p, pIter);
166995 rbuCreateImposterTable2(p, pIter);
166996 zWrite = (pIter->eType==RBU_PK_VTAB ? "" : "rbu_imp_");
167000 p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pInsert, pz,
167012 p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pDelete, pz,
167019 if( rbuIsVacuum(p)==0 && pIter->abIndexed ){
167021 if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){
167029 , p->zStateDb, pIter->zDataTbl
167030 , (pIter->eType==RBU_PK_EXTERNAL ? ", 0 AS rbu_rowid" : "")
167031 , pIter->zDataTbl
167054 if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){
167064 rbuObjIterPrepareTmpInsert(p, pIter, zCollist, zRbuRowid);
167073 p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz,
167079 pIter->zDataTbl, zLimit
167107 RbuObjIter *pIter, /* Object iterator */
167122 for(pp=&pIter->pRbuUpdate; *pp; pp=&((*pp)->pNext)){
167126 pUp->pNext = pIter->pRbuUpdate;
167127 pIter->pRbuUpdate = pUp;
167136 for(pp=&pIter->pRbuUpdate; *pp!=pUp; pp=&((*pp)->pNext));
167141 pUp = (RbuUpdateStmt*)rbuMalloc(p, sizeof(RbuUpdateStmt)+pIter->nTblCol+1);
167145 char *zWhere = rbuObjIterGetWhere(p, pIter);
167146 char *zSet = rbuObjIterGetSetlist(p, pIter, zMask);
167150 memcpy(pUp->zMask, zMask, pIter->nTblCol);
167151 pUp->pNext = pIter->pRbuUpdate;
167152 pIter->pRbuUpdate = pUp;
167157 if( pIter->eType!=RBU_PK_VTAB ) zPrefix = "rbu_imp_";
167159 zPrefix, pIter->zTbl, zSet, zWhere
167814 RbuObjIter *pIter = &p->objiter;
167820 assert( eType!=RBU_DELETE || pIter->zIdx==0 );
167834 pWriter = pIter->pDelete;
167836 pWriter = pIter->pInsert;
167839 for(i=0; i<pIter->nCol; i++){
167844 && pIter->zIdx==0 && pIter->eType==RBU_PK_IPK && pIter->abTblPk[i]
167845 && sqlite3_column_type(pIter->pSelect, i)==SQLITE_NULL
167852 if( eType==RBU_DELETE && pIter->abTblPk[i]==0 ){
167856 pVal = sqlite3_column_value(pIter->pSelect, i);
167860 if( pIter->zIdx==0 ){
167861 if( pIter->eType==RBU_PK_VTAB
167862 || pIter->eType==RBU_PK_NONE
167863 || (pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p))
167872 assertColumnName(pIter->pSelect, pIter->nCol+1,
167875 pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);
167876 p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);
167897 RbuObjIter *pIter = &p->objiter;
167906 assert( eType!=RBU_UPDATE || pIter->zIdx==0 );
167908 if( pIter->zIdx==0 && (eType==RBU_IDX_DELETE || eType==RBU_IDX_INSERT) ){
167912 if( pIter->zIdx==0 ){
167926 rbuGetUpdateStmt(p, pIter, zMask, &pUpdate);
167929 for(i=0; p->rc==SQLITE_OK && i<pIter->nCol; i++){
167930 char c = zMask[pIter->aiSrcOrder[i]];
167931 pVal = sqlite3_column_value(pIter->pSelect, i);
167932 if( pIter->abTblPk[i] || c!='.' ){
167937 && (pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE)
167940 assertColumnName(pIter->pSelect, pIter->nCol+1, "rbu_rowid");
167941 pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);
167942 p->rc = sqlite3_bind_value(pUpdate, pIter->nCol+1, pVal);
168127 RbuObjIter *pIter = &p->objiter;
168137 while( p->rc==SQLITE_OK && pIter->zTbl ){
168139 if( pIter->bCleanup ){
168143 if( rbuIsVacuum(p)==0 && pIter->abIndexed ){
168145 "DELETE FROM %s.'rbu_tmp_%q'", p->zStateDb, pIter->zDataTbl
168149 rbuObjIterPrepareAll(p, pIter, 0);
168153 int rc = sqlite3_step(pIter->pSelect);
168159 p->rc = sqlite3_reset(pIter->pSelect);
168164 rbuObjIterNext(p, pIter);
168168 assert( pIter->zTbl==0 );
168254 RbuObjIter *pIter = &p->objiter;
168257 while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup
168258 || rbuStrCompare(pIter->zIdx, pState->zIdx)
168259 || rbuStrCompare(pIter->zTbl, pState->zTbl)
168261 rc = rbuObjIterNext(p, pIter);
168264 if( rc==SQLITE_OK && !pIter->zTbl ){
173290 sqlite3_changeset_iter *pIter, /* Iterator handle */
173296 *pOp = pIter->op;
173297 *pnCol = pIter->nCol;
173298 *pzTab = pIter->zTab;
173299 if( pbIndirect ) *pbIndirect = pIter->bIndirect;
173310 sqlite3_changeset_iter *pIter, /* Iterator object */
173314 *pabPK = pIter->abPK;
173315 if( pnCol ) *pnCol = pIter->nCol;
173333 sqlite3_changeset_iter *pIter, /* Changeset iterator */
173337 if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_DELETE ){
173340 if( iVal<0 || iVal>=pIter->nCol ){
173343 *ppValue = pIter->apValue[iVal];
173361 sqlite3_changeset_iter *pIter, /* Changeset iterator */
173365 if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_INSERT ){
173368 if( iVal<0 || iVal>=pIter->nCol ){
173371 *ppValue = pIter->apValue[pIter->nCol+iVal];
173380 #define sessionChangesetNew(pIter, iVal) (pIter)->apValue[(pIter)->nCol+(iVal)]
173381 #define sessionChangesetOld(pIter, iVal) (pIter)->apValue[(iVal)]
173395 sqlite3_changeset_iter *pIter, /* Changeset iterator */
173399 if( !pIter->pConflict ){
173402 if( iVal<0 || iVal>=sqlite3_column_count(pIter->pConflict) ){
173405 *ppValue = sqlite3_column_value(pIter->pConflict, iVal);
173418 sqlite3_changeset_iter *pIter, /* Changeset iterator */
173421 if( pIter->pConflict || pIter->apValue ){
173424 *pnOut = pIter->nCol;
173920 sqlite3_changeset_iter *pIter, /* Iterator to read values from */
173938 (void)xValue(pIter, i, &pVal);
173964 sqlite3_changeset_iter *pIter, /* Changeset iterator */
173973 sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);
173974 rc = sessionBindRow(pIter,
174025 sqlite3_changeset_iter *pIter, /* Changeset iterator */
174036 sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);
174044 rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);
174051 pIter->pConflict = p->pSelect;
174052 res = xConflict(pCtx, eType, pIter);
174053 pIter->pConflict = 0;
174059 u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
174060 int nBlob = pIter->in.iNext - pIter->in.iCurrent;
174065 res = xConflict(pCtx, eType+1, pIter);
174118 sqlite3_changeset_iter *pIter, /* Changeset iterator */
174134 sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);
174149 u8 *abPK = (pIter->bPatchset ? p->abPK : 0);
174150 rc = sessionBindRow(pIter, sqlite3changeset_old, nCol, abPK, p->pDelete);
174160 SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry
174164 SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0
174173 sqlite3_value *pOld = sessionChangesetOld(pIter, i);
174174 sqlite3_value *pNew = sessionChangesetNew(pIter, i);
174185 sqlite3_bind_int(p->pUpdate, nCol*3+1, pbRetry==0 || pIter->bPatchset);
174200 SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry
174206 SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0
174212 rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert);
174219 SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, pbReplace
174239 sqlite3_changeset_iter *pIter, /* Changeset iterator to read change from */
174248 rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);
174259 assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE );
174260 rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
174269 assert( pIter->op==SQLITE_INSERT );
174272 rc = sessionBindRow(pIter,
174281 rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);
174350 sqlite3_changeset_iter *pIter, /* Changeset to apply */
174371 pIter->in.bNoDiscard = 1;
174378 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){
174383 sqlite3changeset_op(pIter, &zNew, &nCol, &op, 0);
174389 db, pIter->bPatchset, zTab, &sApply, xConflict, pCtx
174415 sqlite3changeset_pk(pIter, &abPK, 0);
174456 rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);
174459 bPatchset = pIter->bPatchset;
174461 rc = sqlite3changeset_finalize(pIter);
174463 sqlite3changeset_finalize(pIter);
174523 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
174524 int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);
174526 rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);
174551 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
174552 int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
174554 rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);
174697 sqlite3_changeset_iter *pIter, /* Iterator to read from */
174706 while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec) ){
174717 pGrp->bPatch = pIter->bPatchset;
174718 }else if( pIter->bPatchset!=pGrp->bPatch ){
174723 sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect);
174729 sqlite3changeset_pk(pIter, &abPK, 0);
174760 if( sessionGrowHash(pIter->bPatchset, pTab) ){
174765 pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange
174774 if( pIter->bPatchset ){
174787 pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange
174797 if( rc==SQLITE_OK ) rc = pIter->rc;
174889 sqlite3_changeset_iter *pIter; /* Iterator opened on pData/nData */
174892 rc = sqlite3changeset_start(&pIter, nData, pData);
174894 rc = sessionChangesetToHash(pIter, pGrp);
174896 sqlite3changeset_finalize(pIter);
174920 sqlite3_changeset_iter *pIter; /* Iterator opened on pData/nData */
174923 rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);
174925 rc = sessionChangesetToHash(pIter, pGrp);
174927 sqlite3changeset_finalize(pIter);
178112 Fts5PoslistReader *pIter /* Iterator object to initialize */
179919 static int fts5CInstIterNext(CInstIter *pIter){
179921 pIter->iStart = -1;
179922 pIter->iEnd = -1;
179924 while( rc==SQLITE_OK && pIter->iInst<pIter->nInst ){
179926 rc = pIter->pApi->xInst(pIter->pFts, pIter->iInst, &ip, &ic, &io);
179928 if( ic==pIter->iCol ){
179929 int iEnd = io - 1 + pIter->pApi->xPhraseSize(pIter->pFts, ip);
179930 if( pIter->iStart<0 ){
179931 pIter->iStart = io;
179932 pIter->iEnd = iEnd;
179933 }else if( io<=pIter->iEnd ){
179934 if( iEnd>pIter->iEnd ) pIter->iEnd = iEnd;
179939 pIter->iInst++;
179954 CInstIter *pIter
179958 memset(pIter, 0, sizeof(CInstIter));
179959 pIter->pApi = pApi;
179960 pIter->pFts = pFts;
179961 pIter->iCol = iCol;
179962 rc = pApi->xInstCount(pFts, &pIter->nInst);
179965 rc = fts5CInstIterNext(pIter);
180623 static int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader *pIter){
180624 if( sqlite3Fts5PoslistNext64(pIter->a, pIter->n, &pIter->i, &pIter->iPos) ){
180625 pIter->bEof = 1;
180627 return pIter->bEof;
180632 Fts5PoslistReader *pIter /* Iterator object to initialize */
180634 memset(pIter, 0, sizeof(*pIter));
180635 pIter->a = a;
180636 pIter->n = n;
180637 sqlite3Fts5PoslistReaderNext(pIter);
180638 return pIter->bEof;
181875 Fts5IndexIter *pIter; /* Iterator for this term */
182090 if( 0==sqlite3Fts5IterEof(p->pIter) ){
182091 i64 iRowid = p->pIter->iRowid;
182121 Fts5IndexIter *pIter = p->pIter;
182122 if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){
182123 if( pIter->nData==0 ) continue;
182136 sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &aIter[nIter]);
182226 a = (u8*)pTerm->pIter->pData;
182227 n = pTerm->pIter->nData;
182424 Fts5IndexIter *pIter, /* Iterator to advance */
182433 iRowid = pIter->iRowid;
182435 int rc = sqlite3Fts5IterNextFrom(pIter, iLast);
182436 if( rc || sqlite3Fts5IterEof(pIter) ){
182441 iRowid = pIter->iRowid;
182461 if( sqlite3Fts5IterEof(p->pIter)==0 ){
182462 i64 iRowid = p->pIter->iRowid;
182464 rc = sqlite3Fts5IterNextFrom(p->pIter, iLast);
182492 Fts5IndexIter *pIter = pTerm->pIter;
182493 if( sqlite3Fts5IterEof(pIter)==0 ){
182494 if( pIter->iRowid==pNode->iRowid && pIter->nData>0 ){
182513 Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;
182514 fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);
182549 if( p->pIter ){
182550 sqlite3Fts5IterClose(p->pIter);
182551 p->pIter = 0;
182558 &p->pIter
182560 assert( rc==SQLITE_OK || p->pIter==0 );
182561 if( p->pIter && 0==sqlite3Fts5IterEof(p->pIter) ){
182686 iLast = pLeft->aTerm[0].pIter->iRowid;
182705 Fts5IndexIter *pIter = pPhrase->aTerm[j].pIter;
182706 if( pIter->iRowid==iLast ) continue;
182708 if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){
182750 if( sqlite3Fts5IterEof(p->pIter)==0 ){
182751 i64 ii = p->pIter->iRowid;
182756 rc = sqlite3Fts5IterNextFrom(p->pIter, iFrom);
182758 rc = sqlite3Fts5IterNext(p->pIter);
182761 if( sqlite3Fts5IterEof(p->pIter)==0 ){
182774 Fts5IndexIter *pIter = pTerm->pIter;
182778 rc = sqlite3Fts5IterNextFrom(pIter, iFrom);
182780 rc = sqlite3Fts5IterNext(pIter);
182783 pNode->bEof = (rc || sqlite3Fts5IterEof(pIter));
182805 Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;
182811 pPhrase->poslist.n = pIter->nData;
182813 pPhrase->poslist.p = (u8*)pIter->pData;
182815 pNode->iRowid = pIter->iRowid;
182830 Fts5IndexIter *pIter = pNode->pNear->apPhrase[0]->aTerm[0].pIter;
182834 rc = sqlite3Fts5IterNextFrom(pIter, iFrom);
182836 rc = sqlite3Fts5IterNext(pIter);
182838 if( rc==SQLITE_OK && sqlite3Fts5IterEof(pIter)==0 ){
183174 sqlite3Fts5IterClose(pTerm->pIter);
183177 sqlite3Fts5IterClose(pSyn->pIter);
184430 *ppCollist = pPhrase->aTerm[0].pIter->pData;
184431 *pnCollist = pPhrase->aTerm[0].pIter->nData;
184880 Fts5HashEntry *pIter;
184881 for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
184882 if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){
184883 Fts5HashEntry *pEntry = pIter;
186262 static int fts5DlidxIterNextR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){
186263 Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];
186265 assert( iLvl<pIter->nLvl );
186267 if( (iLvl+1) < pIter->nLvl ){
186268 fts5DlidxIterNextR(p, pIter, iLvl+1);
186273 FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)
186280 return pIter->aLvl[0].bEof;
186282 static int fts5DlidxIterNext(Fts5Index *p, Fts5DlidxIter *pIter){
186283 return fts5DlidxIterNextR(p, pIter, 0);
186297 static int fts5DlidxIterFirst(Fts5DlidxIter *pIter){
186299 for(i=0; i<pIter->nLvl; i++){
186300 fts5DlidxLvlNext(&pIter->aLvl[i]);
186302 return pIter->aLvl[0].bEof;
186306 static int fts5DlidxIterEof(Fts5Index *p, Fts5DlidxIter *pIter){
186307 return p->rc!=SQLITE_OK || pIter->aLvl[0].bEof;
186310 static void fts5DlidxIterLast(Fts5Index *p, Fts5DlidxIter *pIter){
186314 for(i=pIter->nLvl-1; p->rc==SQLITE_OK && i>=0; i--){
186315 Fts5DlidxLvl *pLvl = &pIter->aLvl[i];
186324 FTS5_DLIDX_ROWID(pIter->iSegid, i-1, pLvl->iLeafPgno)
186382 static int fts5DlidxIterPrevR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){
186383 Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];
186385 assert( iLvl<pIter->nLvl );
186387 if( (iLvl+1) < pIter->nLvl ){
186388 fts5DlidxIterPrevR(p, pIter, iLvl+1);
186393 FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)
186403 return pIter->aLvl[0].bEof;
186405 static int fts5DlidxIterPrev(Fts5Index *p, Fts5DlidxIter *pIter){
186406 return fts5DlidxIterPrevR(p, pIter, 0);
186412 static void fts5DlidxIterFree(Fts5DlidxIter *pIter){
186413 if( pIter ){
186415 for(i=0; i<pIter->nLvl; i++){
186416 fts5DataRelease(pIter->aLvl[i].pData);
186418 sqlite3_free(pIter);
186428 Fts5DlidxIter *pIter = 0;
186436 pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);
186442 pIter = pNew;
186448 pIter->nLvl = i+1;
186453 pIter->iSegid = iSegid;
186455 fts5DlidxIterFirst(pIter);
186457 fts5DlidxIterLast(p, pIter);
186462 fts5DlidxIterFree(pIter);
186463 pIter = 0;
186466 return pIter;
186469 static i64 fts5DlidxIterRowid(Fts5DlidxIter *pIter){
186470 return pIter->aLvl[0].iRowid;
186472 static int fts5DlidxIterPgno(Fts5DlidxIter *pIter){
186473 return pIter->aLvl[0].iLeafPgno;
186481 Fts5SegIter *pIter /* Iterator to advance to next page */
186484 Fts5StructureSegment *pSeg = pIter->pSeg;
186485 fts5DataRelease(pIter->pLeaf);
186486 pIter->iLeafPgno++;
186487 if( pIter->pNextLeaf ){
186488 pIter->pLeaf = pIter->pNextLeaf;
186489 pIter->pNextLeaf = 0;
186490 }else if( pIter->iLeafPgno<=pSeg->pgnoLast ){
186491 pIter->pLeaf = fts5DataRead(p,
186492 FTS5_SEGMENT_ROWID(pSeg->iSegid, pIter->iLeafPgno)
186495 pIter->pLeaf = 0;
186497 pLeaf = pIter->pLeaf;
186500 pIter->iPgidxOff = pLeaf->szLeaf;
186502 pIter->iEndofDoclist = pLeaf->nn+1;
186504 pIter->iPgidxOff += fts5GetVarint32(&pLeaf->p[pIter->iPgidxOff],
186505 pIter->iEndofDoclist
186538 static void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){
186540 int iOff = pIter->iLeafOffset; /* Offset to read at */
186541 ASSERT_SZLEAF_OK(pIter->pLeaf);
186543 int iEod = MIN(pIter->iEndofDoclist, pIter->pLeaf->szLeaf);
186544 pIter->bDel = 0;
186545 pIter->nPos = 1;
186546 if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){
186547 pIter->bDel = 1;
186549 if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){
186550 pIter->nPos = 1;
186553 pIter->nPos = 0;
186558 fts5FastGetVarint32(pIter->pLeaf->p, iOff, nSz);
186559 pIter->bDel = (nSz & 0x0001);
186560 pIter->nPos = nSz>>1;
186561 assert_nc( pIter->nPos>=0 );
186563 pIter->iLeafOffset = iOff;
186567 static void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){
186568 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
186569 int iOff = pIter->iLeafOffset;
186571 ASSERT_SZLEAF_OK(pIter->pLeaf);
186572 if( iOff>=pIter->pLeaf->szLeaf ){
186573 fts5SegIterNextPage(p, pIter);
186574 if( pIter->pLeaf==0 ){
186579 a = pIter->pLeaf->p;
186581 iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);
186582 pIter->iLeafOffset = iOff;
186600 static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
186601 u8 *a = pIter->pLeaf->p; /* Buffer to read data from */
186602 int iOff = pIter->iLeafOffset; /* Offset to read at */
186606 if( iOff+nNew>pIter->pLeaf->nn ){
186610 pIter->term.n = nKeep;
186611 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
186613 pIter->iTermLeafOffset = iOff;
186614 pIter->iTermLeafPgno = pIter->iLeafPgno;
186615 pIter->iLeafOffset = iOff;
186617 if( pIter->iPgidxOff>=pIter->pLeaf->nn ){
186618 pIter->iEndofDoclist = pIter->pLeaf->nn+1;
186621 pIter->iPgidxOff += fts5GetVarint32(&a[pIter->iPgidxOff], nExtra);
186622 pIter->iEndofDoclist += nExtra;
186625 fts5SegIterLoadRowid(p, pIter);
186632 static void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){
186633 if( pIter->flags & FTS5_SEGITER_REVERSE ){
186634 pIter->xNext = fts5SegIterNext_Reverse;
186636 pIter->xNext = fts5SegIterNext_None;
186638 pIter->xNext = fts5SegIterNext;
186653 Fts5SegIter *pIter /* Object to populate */
186661 assert( pIter->pLeaf==0 );
186666 memset(pIter, 0, sizeof(*pIter));
186667 fts5SegIterSetNext(p, pIter);
186668 pIter->pSeg = pSeg;
186669 pIter->iLeafPgno = pSeg->pgnoFirst-1;
186670 fts5SegIterNextPage(p, pIter);
186674 pIter->iLeafOffset = 4;
186675 assert_nc( pIter->pLeaf->nn>4 );
186676 assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
186677 pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
186678 fts5SegIterLoadTerm(p, pIter, 0);
186679 fts5SegIterLoadNPos(p, pIter);
186698 static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){
186700 int n = pIter->pLeaf->szLeaf;
186701 int i = pIter->iLeafOffset;
186702 u8 *a = pIter->pLeaf->p;
186705 if( n>pIter->iEndofDoclist ){
186706 n = pIter->iEndofDoclist;
186709 ASSERT_SZLEAF_OK(pIter->pLeaf);
186727 pIter->iRowid += iDelta;
186730 if( iRowidOffset>=pIter->nRowidOffset ){
186731 int nNew = pIter->nRowidOffset + 8;
186732 int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));
186737 pIter->aRowidOffset = aNew;
186738 pIter->nRowidOffset = nNew;
186741 pIter->aRowidOffset[iRowidOffset++] = pIter->iLeafOffset;
186742 pIter->iLeafOffset = i;
186744 pIter->iRowidOffset = iRowidOffset;
186745 fts5SegIterLoadNPos(p, pIter);
186751 static void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){
186752 assert( pIter->flags & FTS5_SEGITER_REVERSE );
186753 assert( pIter->flags & FTS5_SEGITER_ONETERM );
186755 fts5DataRelease(pIter->pLeaf);
186756 pIter->pLeaf = 0;
186757 while( p->rc==SQLITE_OK && pIter->iLeafPgno>pIter->iTermLeafPgno ){
186759 pIter->iLeafPgno--;
186761 pIter->pSeg->iSegid, pIter->iLeafPgno
186767 if( pIter->iLeafPgno==pIter->iTermLeafPgno ){
186768 assert( pIter->pLeaf==0 );
186769 if( pIter->iTermLeafOffset<pNew->szLeaf ){
186770 pIter->pLeaf = pNew;
186771 pIter->iLeafOffset = pIter->iTermLeafOffset;
186777 pIter->pLeaf = pNew;
186778 pIter->iLeafOffset = iRowidOff;
186782 if( pIter->pLeaf ){
186783 u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset];
186784 pIter->iLeafOffset += fts5GetVarint(a, (u64*)&pIter->iRowid);
186792 if( pIter->pLeaf ){
186793 pIter->iEndofDoclist = pIter->pLeaf->nn+1;
186794 fts5SegIterReverseInitPage(p, pIter);
186803 static int fts5MultiIterIsEmpty(Fts5Index *p, Fts5Iter *pIter){
186804 Fts5SegIter *pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];
186815 Fts5SegIter *pIter, /* Iterator to advance */
186818 assert( pIter->flags & FTS5_SEGITER_REVERSE );
186819 assert( pIter->pNextLeaf==0 );
186822 if( pIter->iRowidOffset>0 ){
186823 u8 *a = pIter->pLeaf->p;
186827 pIter->iRowidOffset--;
186828 pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset];
186829 fts5SegIterLoadNPos(p, pIter);
186830 iOff = pIter->iLeafOffset;
186832 iOff += pIter->nPos;
186835 pIter->iRowid -= iDelta;
186837 fts5SegIterReverseNewPage(p, pIter);
186849 Fts5SegIter *pIter, /* Iterator to advance */
186855 assert( (pIter->flags & FTS5_SEGITER_REVERSE)==0 );
186858 ASSERT_SZLEAF_OK(pIter->pLeaf);
186859 iOff = pIter->iLeafOffset;
186862 if( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){
186863 fts5SegIterNextPage(p, pIter);
186864 if( p->rc || pIter->pLeaf==0 ) return;
186865 pIter->iRowid = 0;
186869 if( iOff<pIter->iEndofDoclist ){
186872 iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], (u64*)&iDelta);
186873 pIter->iLeafOffset = iOff;
186874 pIter->iRowid += iDelta;
186875 }else if( (pIter->flags & FTS5_SEGITER_ONETERM)==0 ){
186876 if( pIter->pSeg ){
186878 if( iOff!=fts5LeafFirstTermOff(pIter->pLeaf) ){
186879 iOff += fts5GetVarint32(&pIter->pLeaf->p[iOff], nKeep);
186881 pIter->iLeafOffset = iOff;
186882 fts5SegIterLoadTerm(p, pIter, nKeep);
186890 pIter->pLeaf->p = (u8*)pList;
186891 pIter->pLeaf->nn = nList;
186892 pIter->pLeaf->szLeaf = nList;
186893 pIter->iEndofDoclist = nList;
186894 sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm);
186895 pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);
186903 fts5SegIterLoadNPos(p, pIter);
186907 fts5DataRelease(pIter->pLeaf);
186908 pIter->pLeaf = 0;
186921 Fts5SegIter *pIter, /* Iterator to advance */
186924 Fts5Data *pLeaf = pIter->pLeaf;
186939 iOff = pIter->iLeafOffset + pIter->nPos;
186943 assert_nc( iOff<=pIter->iEndofDoclist );
186944 if( iOff>=pIter->iEndofDoclist ){
186952 pIter->iRowid += iDelta;
186955 pIter->iLeafOffset = iOff;
186957 }else if( pIter->pSeg==0 ){
186961 assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm );
186962 if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){
186967 fts5DataRelease(pIter->pLeaf);
186968 pIter->pLeaf = 0;
186970 pIter->pLeaf->p = (u8*)pList;
186971 pIter->pLeaf->nn = nList;
186972 pIter->pLeaf->szLeaf = nList;
186973 pIter->iEndofDoclist = nList+1;
186974 sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm),
186976 pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);
186983 fts5SegIterNextPage(p, pIter);
186984 pLeaf = pIter->pLeaf;
186988 iOff += sqlite3Fts5GetVarint(&pLeaf->p[iOff], (u64*)&pIter->iRowid);
186989 pIter->iLeafOffset = iOff;
186992 pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(
186993 &pLeaf->p[pLeaf->szLeaf], pIter->iEndofDoclist
186999 pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(
187002 pIter->iLeafOffset = iOff;
187003 pIter->iEndofDoclist = iOff;
187015 if( pIter->pLeaf ){
187017 if( pIter->flags & FTS5_SEGITER_ONETERM ){
187018 fts5DataRelease(pIter->pLeaf);
187019 pIter->pLeaf = 0;
187021 fts5SegIterLoadTerm(p, pIter, nKeep);
187022 fts5SegIterLoadNPos(p, pIter);
187035 fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);
187036 pIter->bDel = (nSz & 0x0001);
187037 pIter->nPos = nSz>>1;
187038 assert_nc( pIter->nPos>=0 );
187055 static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){
187056 Fts5DlidxIter *pDlidx = pIter->pDlidx;
187061 int iSegid = pIter->pSeg->iSegid;
187065 Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */
187071 if( pIter->iTermLeafPgno==pIter->iLeafPgno ){
187072 iPoslist = pIter->iTermLeafOffset;
187077 pIter->iLeafOffset = iPoslist;
187082 if( pIter->iEndofDoclist>=pLeaf->szLeaf ){
187084 Fts5StructureSegment *pSeg = pIter->pSeg;
187088 for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){
187117 fts5DataRelease(pIter->pLeaf);
187118 pIter->pLeaf = pLast;
187119 pIter->iLeafPgno = pgnoLast;
187121 iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);
187122 pIter->iLeafOffset = iOff;
187125 pIter->iEndofDoclist = pLast->nn+1;
187127 pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);
187132 fts5SegIterReverseInitPage(p, pIter);
187141 static void fts5SegIterLoadDlidx(Fts5Index *p, Fts5SegIter *pIter){
187142 int iSeg = pIter->pSeg->iSegid;
187143 int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);
187144 Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */
187146 assert( pIter->flags & FTS5_SEGITER_ONETERM );
187147 assert( pIter->pDlidx==0 );
187152 if( pIter->iTermLeafPgno==pIter->iLeafPgno
187153 && pIter->iEndofDoclist<pLeaf->szLeaf
187158 pIter->pDlidx = fts5DlidxIterInit(p, bRev, iSeg, pIter->iTermLeafPgno);
187178 Fts5SegIter *pIter, /* Iterator to seek */
187182 const u8 *a = pIter->pLeaf->p;
187183 int szLeaf = pIter->pLeaf->szLeaf;
187184 int n = pIter->pLeaf->nn;
187247 fts5DataRelease(pIter->pLeaf);
187248 pIter->pLeaf = 0;
187252 fts5SegIterNextPage(p, pIter);
187253 if( pIter->pLeaf==0 ) return;
187254 a = pIter->pLeaf->p;
187255 if( fts5LeafIsTermless(pIter->pLeaf)==0 ){
187256 iPgidx = pIter->pLeaf->szLeaf;
187257 iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);
187258 if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){
187263 n = pIter->pLeaf->nn;
187273 pIter->iLeafOffset = iOff + nNew;
187274 pIter->iTermLeafOffset = pIter->iLeafOffset;
187275 pIter->iTermLeafPgno = pIter->iLeafPgno;
187277 fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);
187278 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
187281 pIter->iEndofDoclist = pIter->pLeaf->nn+1;
187285 pIter->iEndofDoclist = iTermOff + nExtra;
187287 pIter->iPgidxOff = iPgidx;
187289 fts5SegIterLoadRowid(p, pIter);
187290 fts5SegIterLoadNPos(p, pIter);
187317 Fts5SegIter *pIter /* Object to populate */
187326 memset(pIter, 0, sizeof(*pIter));
187327 pIter->pSeg = pSeg;
187347 pIter->iLeafPgno = iPg - 1;
187348 fts5SegIterNextPage(p, pIter);
187350 if( pIter->pLeaf ){
187351 fts5LeafSeek(p, bGe, pIter, pTerm, nTerm);
187355 pIter->flags |= FTS5_SEGITER_ONETERM;
187356 if( pIter->pLeaf ){
187358 pIter->flags |= FTS5_SEGITER_REVERSE;
187361 fts5SegIterLoadDlidx(p, pIter);
187364 fts5SegIterReverse(p, pIter);
187369 fts5SegIterSetNext(p, pIter);
187380 || pIter->pLeaf==0 /* 2 */
187381 || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0 /* 3 */
187382 || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0) /* 4 */
187398 Fts5SegIter *pIter /* Object to populate */
187413 pIter->flags |= FTS5_SEGITER_ONETERM;
187421 sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);
187426 pIter->pLeaf = pLeaf;
187427 pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);
187428 pIter->iEndofDoclist = pLeaf->nn;
187431 pIter->flags |= FTS5_SEGITER_REVERSE;
187432 fts5SegIterReverseInitPage(p, pIter);
187434 fts5SegIterLoadNPos(p, pIter);
187438 fts5SegIterSetNext(p, pIter);
187444 static void fts5SegIterClear(Fts5SegIter *pIter){
187445 fts5BufferFree(&pIter->term);
187446 fts5DataRelease(pIter->pLeaf);
187447 fts5DataRelease(pIter->pNextLeaf);
187448 fts5DlidxIterFree(pIter->pDlidx);
187449 sqlite3_free(pIter->aRowidOffset);
187450 memset(pIter, 0, sizeof(Fts5SegIter));
187462 Fts5Iter *pIter,
187467 int i1 = p1 - pIter->aSeg;
187468 int i2 = p2 - pIter->aSeg;
187483 res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : 1;
187503 static void fts5AssertMultiIterSetup(Fts5Index *p, Fts5Iter *pIter){
187505 Fts5SegIter *pFirst = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
187508 assert( (pFirst->pLeaf==0)==pIter->base.bEof );
187511 for(i=0; i<pIter->nSeg; i++){
187512 Fts5SegIter *p1 = &pIter->aSeg[i];
187516 || p1->iRowid==pIter->iSwitchRowid
187517 || (p1->iRowid<pIter->iSwitchRowid)==pIter->bRev
187521 for(i=0; i<pIter->nSeg; i+=2){
187522 Fts5SegIter *p1 = &pIter->aSeg[i];
187523 Fts5SegIter *p2 = &pIter->aSeg[i+1];
187524 Fts5CResult *pRes = &pIter->aFirst[(pIter->nSeg + i) / 2];
187525 fts5AssertComparisonResult(pIter, p1, p2, pRes);
187528 for(i=1; i<(pIter->nSeg / 2); i+=2){
187529 Fts5SegIter *p1 = &pIter->aSeg[ pIter->aFirst[i*2].iFirst ];
187530 Fts5SegIter *p2 = &pIter->aSeg[ pIter->aFirst[i*2+1].iFirst ];
187531 Fts5CResult *pRes = &pIter->aFirst[i];
187532 fts5AssertComparisonResult(pIter, p1, p2, pRes);
187548 static int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){
187554 Fts5CResult *pRes = &pIter->aFirst[iOut];
187556 assert( iOut<pIter->nSeg && iOut>0 );
187557 assert( pIter->bRev==0 || pIter->bRev==1 );
187559 if( iOut>=(pIter->nSeg/2) ){
187560 i1 = (iOut - pIter->nSeg/2) * 2;
187563 i1 = pIter->aFirst[iOut*2].iFirst;
187564 i2 = pIter->aFirst[iOut*2+1].iFirst;
187566 p1 = &pIter->aSeg[i1];
187567 p2 = &pIter->aSeg[i2];
187584 res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1;
187604 Fts5SegIter *pIter, /* Iterator to advance */
187607 assert( iLeafPgno>pIter->iLeafPgno );
187609 if( iLeafPgno>pIter->pSeg->pgnoLast ){
187612 fts5DataRelease(pIter->pNextLeaf);
187613 pIter->pNextLeaf = 0;
187614 pIter->iLeafPgno = iLeafPgno-1;
187615 fts5SegIterNextPage(p, pIter);
187616 assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );
187620 u8 *a = pIter->pLeaf->p;
187621 int n = pIter->pLeaf->szLeaf;
187623 iOff = fts5LeafFirstRowidOff(pIter->pLeaf);
187627 iOff += fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);
187628 pIter->iLeafOffset = iOff;
187629 fts5SegIterLoadNPos(p, pIter);
187642 Fts5SegIter *pIter, /* Iterator to advance */
187645 int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);
187646 Fts5DlidxIter *pDlidx = pIter->pDlidx;
187647 int iLeafPgno = pIter->iLeafPgno;
187650 assert( pIter->flags & FTS5_SEGITER_ONETERM );
187651 assert( pIter->pDlidx );
187652 assert( pIter->pLeaf );
187659 assert_nc( iLeafPgno>=pIter->iLeafPgno || p->rc );
187660 if( iLeafPgno>pIter->iLeafPgno ){
187661 fts5SegIterGotoPage(p, pIter, iLeafPgno);
187665 assert( pIter->pNextLeaf==0 );
187666 assert( iMatch<pIter->iRowid );
187672 assert( fts5DlidxIterEof(p, pDlidx) || iLeafPgno<=pIter->iLeafPgno );
187674 if( iLeafPgno<pIter->iLeafPgno ){
187675 pIter->iLeafPgno = iLeafPgno+1;
187676 fts5SegIterReverseNewPage(p, pIter);
187682 if( bMove && p->rc==SQLITE_OK ) pIter->xNext(p, pIter, 0);
187683 if( pIter->pLeaf==0 ) break;
187684 if( bRev==0 && pIter->iRowid>=iMatch ) break;
187685 if( bRev!=0 && pIter->iRowid<=iMatch ) break;
187694 static void fts5MultiIterFree(Fts5Iter *pIter){
187695 if( pIter ){
187697 for(i=0; i<pIter->nSeg; i++){
187698 fts5SegIterClear(&pIter->aSeg[i]);
187700 fts5StructureRelease(pIter->pStruct);
187701 fts5BufferFree(&pIter->poslist);
187702 sqlite3_free(pIter);
187708 Fts5Iter *pIter, /* Iterator to update aFirst[] array for */
187713 for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){
187715 if( (iEq = fts5MultiIterDoCompare(pIter, i)) ){
187716 Fts5SegIter *pSeg = &pIter->aSeg[iEq];
187719 i = pIter->nSeg + iEq;
187735 Fts5Iter *pIter, /* Iterator to update aFirst[] array for */
187739 Fts5SegIter *pNew = &pIter->aSeg[iChanged];
187741 if( pNew->iRowid==pIter->iSwitchRowid
187742 || (pNew->iRowid<pIter->iSwitchRowid)==pIter->bRev
187745 Fts5SegIter *pOther = &pIter->aSeg[iChanged ^ 0x0001];
187746 pIter->iSwitchRowid = pIter->bRev ? SMALLEST_INT64 : LARGEST_INT64;
187747 for(i=(pIter->nSeg+iChanged)/2; 1; i=i/2){
187748 Fts5CResult *pRes = &pIter->aFirst[i];
187756 }else if( (pOther->iRowid>pNew->iRowid)==pIter->bRev ){
187757 pIter->iSwitchRowid = pOther->iRowid;
187759 }else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){
187760 pIter->iSwitchRowid = pOther->iRowid;
187763 pRes->iFirst = (u16)(pNew - pIter->aSeg);
187766 pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];
187777 static void fts5MultiIterSetEof(Fts5Iter *pIter){
187778 Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
187779 pIter->base.bEof = pSeg->pLeaf==0;
187780 pIter->iSwitchRowid = pSeg->iRowid;
187792 Fts5Iter *pIter,
187798 int iFirst = pIter->aFirst[1].iFirst;
187800 Fts5SegIter *pSeg = &pIter->aSeg[iFirst];
187809 || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)
187811 fts5MultiIterAdvanced(p, pIter, iFirst, 1);
187812 fts5MultiIterSetEof(pIter);
187813 pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];
187817 fts5AssertMultiIterSetup(p, pIter);
187818 assert( pSeg==&pIter->aSeg[pIter->aFirst[1].iFirst] && pSeg->pLeaf );
187819 if( pIter->bSkipEmpty==0 || pSeg->nPos ){
187820 pIter->xSetOutputs(pIter, pSeg);
187829 Fts5Iter *pIter,
187832 assert( pIter->bSkipEmpty );
187835 int iFirst = pIter->aFirst[1].iFirst;
187836 Fts5SegIter *pSeg = &pIter->aSeg[iFirst];
187842 || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)
187844 fts5MultiIterAdvanced(p, pIter, iFirst, 1);
187845 fts5MultiIterSetEof(pIter);
187850 fts5AssertMultiIterSetup(p, pIter);
187852 }while( fts5MultiIterIsEmpty(p, pIter) );
188136 static void fts5IterSetOutputs_None(Fts5Iter *pIter, Fts5SegIter *pSeg){
188137 assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_NONE );
188138 pIter->base.iRowid = pSeg->iRowid;
188139 pIter->base.nData = pSeg->nPos;
188146 static void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){
188147 pIter->base.iRowid = pSeg->iRowid;
188148 pIter->base.nData = pSeg->nPos;
188150 assert( pIter->pIndex->pConfig->eDetail!=FTS5_DETAIL_NONE );
188151 assert( pIter->pColset==0 );
188156 pIter->base.pData = &pSeg->pLeaf->p[pSeg->iLeafOffset];
188161 fts5BufferZero(&pIter->poslist);
188162 fts5SegiterPoslist(pIter->pIndex, pSeg, 0, &pIter->poslist);
188163 pIter->base.pData = pIter->poslist.p;
188172 static void fts5IterSetOutputs_Col(Fts5Iter *pIter, Fts5SegIter *pSeg){
188173 fts5BufferZero(&pIter->poslist);
188174 fts5SegiterPoslist(pIter->pIndex, pSeg, pIter->pColset, &pIter->poslist);
188175 pIter->base.iRowid = pSeg->iRowid;
188176 pIter->base.pData = pIter->poslist.p;
188177 pIter->base.nData = pIter->poslist.n;
188190 static void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){
188192 assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );
188193 assert( pIter->pColset );
188196 fts5IterSetOutputs_Col(pIter, pSeg);
188201 int *aiCol = pIter->pColset->aiCol;
188202 int *aiColEnd = &aiCol[pIter->pColset->nCol];
188204 u8 *aOut = pIter->poslist.p;
188207 pIter->base.iRowid = pSeg->iRowid;
188222 pIter->base.pData = pIter->poslist.p;
188223 pIter->base.nData = aOut - pIter->poslist.p;
188230 static void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){
188231 Fts5Colset *pColset = pIter->pColset;
188232 pIter->base.iRowid = pSeg->iRowid;
188234 assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_FULL );
188242 pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]);
188243 pIter->base.pData = a;
188245 fts5BufferZero(&pIter->poslist);
188246 fts5IndexExtractColset(pColset, a, pSeg->nPos, &pIter->poslist);
188247 pIter->base.pData = pIter->poslist.p;
188248 pIter->base.nData = pIter->poslist.n;
188254 fts5BufferZero(&pIter->poslist);
188255 fts5SegiterPoslist(pIter->pIndex, pSeg, pColset, &pIter->poslist);
188256 pIter->base.pData = pIter->poslist.p;
188257 pIter->base.nData = pIter->poslist.n;
188261 static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){
188263 Fts5Config *pConfig = pIter->pIndex->pConfig;
188265 pIter->xSetOutputs = fts5IterSetOutputs_None;
188268 else if( pIter->pColset==0 ){
188269 pIter->xSetOutputs = fts5IterSetOutputs_Nocolset;
188273 pIter->xSetOutputs = fts5IterSetOutputs_Full;
188279 pIter->xSetOutputs = fts5IterSetOutputs_Col100;
188280 sqlite3Fts5BufferSize(pRc, &pIter->poslist, pConfig->nCol);
188282 pIter->xSetOutputs = fts5IterSetOutputs_Col;
188345 Fts5SegIter *pIter = &pNew->aSeg[iIter++];
188346 fts5SegIterHashInit(p, pTerm, nTerm, flags, pIter);
188351 Fts5SegIter *pIter = &pNew->aSeg[iIter++];
188353 fts5SegIterInit(p, pSeg, pIter);
188355 fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter);
188410 Fts5SegIter *pIter = &pNew->aSeg[1];
188412 pIter->flags = FTS5_SEGITER_ONETERM;
188414 pIter->pLeaf = pData;
188415 pIter->iLeafOffset = fts5GetVarint(pData->p, (u64*)&pIter->iRowid);
188416 pIter->iEndofDoclist = pData->nn;
188420 pIter->flags |= FTS5_SEGITER_REVERSE;
188421 fts5SegIterReverseInitPage(p, pIter);
188423 fts5SegIterLoadNPos(p, pIter);
188429 fts5SegIterSetNext(p, pIter);
188441 static int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){
188443 || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof
188445 return (p->rc || pIter->base.bEof);
188453 static i64 fts5MultiIterRowid(Fts5Iter *pIter){
188454 assert( pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf );
188455 return pIter->aSeg[ pIter->aFirst[1].iFirst ].iRowid;
188463 Fts5Iter *pIter,
188468 fts5MultiIterNext(p, pIter, 1, iMatch);
188469 if( fts5MultiIterEof(p, pIter) ) break;
188470 iRowid = fts5MultiIterRowid(pIter);
188471 if( pIter->bRev==0 && iRowid>=iMatch ) break;
188472 if( pIter->bRev!=0 && iRowid<=iMatch ) break;
188480 static const u8 *fts5MultiIterTerm(Fts5Iter *pIter, int *pn){
188481 Fts5SegIter *p = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
189051 static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){
189055 for(i=0; i<pIter->nSeg; i++){
189056 Fts5SegIter *pSeg = &pIter->aSeg[i];
189129 Fts5Iter *pIter = 0; /* Iterator to read input data */
189182 for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, iLvl, nInput, &pIter);
189183 fts5MultiIterEof(p, pIter)==0;
189184 fts5MultiIterNext(p, pIter, 0, 0)
189186 Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
189194 pTerm = fts5MultiIterTerm(pIter, &nTerm);
189207 fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));
189228 if( fts5MultiIterEof(p, pIter) ){
189250 fts5TrimSegments(p, pIter);
189254 fts5MultiIterFree(pIter);
189705 static void fts5DoclistIterNext(Fts5DoclistIter *pIter){
189706 u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist;
189708 assert( pIter->aPoslist );
189709 if( p>=pIter->aEof ){
189710 pIter->aPoslist = 0;
189715 pIter->iRowid += iDelta;
189720 pIter->nSize = fts5GetVarint32(p, nPos);
189721 pIter->nPoslist = (nPos>>1);
189723 pIter->nPoslist = ((int)(p[0])) >> 1;
189724 pIter->nSize = 1;
189727 pIter->aPoslist = p;
189733 Fts5DoclistIter *pIter
189735 memset(pIter, 0, sizeof(*pIter));
189736 pIter->aPoslist = pBuf->p;
189737 pIter->aEof = &pBuf->p[pBuf->n];
189738 fts5DoclistIterNext(pIter);
190340 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
190341 assert( pIter->pIndex->rc==SQLITE_OK );
190342 fts5MultiIterNext(pIter->pIndex, pIter, 0, 0);
190343 return fts5IndexReturn(pIter->pIndex);
190350 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
190351 Fts5Index *p = pIter->pIndex;
190353 assert( pIter->pIndex->rc==SQLITE_OK );
190355 fts5MultiIterNext(p, pIter, 0, 0);
190357 Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];
190361 pIter->base.bEof = 1;
190365 return fts5IndexReturn(pIter->pIndex);
190374 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
190375 fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch);
190376 return fts5IndexReturn(pIter->pIndex);
190394 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
190395 Fts5Index *pIndex = pIter->pIndex;
190396 fts5MultiIterFree(pIter);
190561 Fts5IndexIter *pIter = 0;
190562 int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);
190564 while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){
190565 i64 rowid = pIter->iRowid;
190571 for(sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &sReader);
190581 rc = sqlite3Fts5IterNext(pIter);
190584 sqlite3Fts5IterClose(pIter);
190889 Fts5Iter *pIter; /* Used to iterate through entire index */
190926 for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, -1, 0, &pIter);
190927 fts5MultiIterEof(p, pIter)==0;
190928 fts5MultiIterNext(p, pIter, 0, 0)
190933 i64 iRowid = fts5MultiIterRowid(pIter);
190934 char *z = (char*)fts5MultiIterTerm(pIter, &n);
190940 if( 0==fts5MultiIterIsEmpty(p, pIter) ){
190945 fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist);
190955 fts5MultiIterFree(pIter);
193411 Fts5PhraseIter *pIter,
193415 if( pIter->a>=pIter->b ){
193420 pIter->a += fts5GetVarint32(pIter->a, iVal);
193422 pIter->a += fts5GetVarint32(pIter->a, iVal);
193425 pIter->a += fts5GetVarint32(pIter->a, iVal);
193434 Fts5PhraseIter *pIter,
193439 int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);
193441 pIter->b = &pIter->a[n];
193444 fts5ApiPhraseNext(pCtx, pIter, piCol, piOff);
193451 Fts5PhraseIter *pIter,
193458 if( pIter->a>=pIter->b ){
193462 pIter->a += fts5GetVarint32(&pIter->a[0], iIncr);
193468 if( pIter->a>=pIter->b ){
193472 if( pIter->a[0]==0x01 ) break;
193473 pIter->a += fts5GetVarint32(pIter->a, dummy);
193475 pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);
193482 Fts5PhraseIter *pIter,
193495 pIter->a = &pSorter->aPoslist[i1];
193497 rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n);
193500 pIter->b = &pIter->a[n];
193502 fts5ApiPhraseNextColumn(pCtx, pIter, piCol);
193506 rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);
193508 pIter->b = &pIter->a[n];
193511 }else if( pIter->a[0]==0x01 ){
193512 pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);
197304 Fts5IndexIter *pIter; /* Term/rowid iterator object */
197598 sqlite3Fts5IterClose(pCsr->pIter);
197599 pCsr->pIter = 0;
197637 if( sqlite3Fts5IterEof(pCsr->pIter) ){
197643 zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
197664 pPos = pCsr->pIter->pData;
197665 nPos = pCsr->pIter->nData;
197668 pPos = pCsr->pIter->pData;
197669 nPos = pCsr->pIter->nData;
197714 rc = sqlite3Fts5IterNextScan(pCsr->pIter);
197718 zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
197722 if( sqlite3Fts5IterEof(pCsr->pIter) ) break;
197787 rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);