MCPcopy Create free account
hub / github.com/audacity/audacity / dbdataNext

Function dbdataNext

lib-src/sqlite/shell.c:10805–10994  ·  view source on GitHub ↗

** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry. */

Source from the content-addressed store, hash-verified

10803** Move an sqlite_dbdata or sqlite_dbptr cursor to the next entry.
10804*/
10805static int dbdataNext(sqlite3_vtab_cursor *pCursor){
10806 DbdataCursor *pCsr = (DbdataCursor*)pCursor;
10807 DbdataTable *pTab = (DbdataTable*)pCursor->pVtab;
10808
10809 pCsr->iRowid++;
10810 while( 1 ){
10811 int rc;
10812 int iOff = (pCsr->iPgno==1 ? 100 : 0);
10813 int bNextPage = 0;
10814
10815 if( pCsr->aPage==0 ){
10816 while( 1 ){
10817 if( pCsr->bOnePage==0 && pCsr->iPgno>pCsr->szDb ) return SQLITE_OK;
10818 rc = dbdataLoadPage(pCsr, pCsr->iPgno, &pCsr->aPage, &pCsr->nPage);
10819 if( rc!=SQLITE_OK ) return rc;
10820 if( pCsr->aPage ) break;
10821 pCsr->iPgno++;
10822 }
10823 pCsr->iCell = pTab->bPtr ? -2 : 0;
10824 pCsr->nCell = get_uint16(&pCsr->aPage[iOff+3]);
10825 }
10826
10827 if( pTab->bPtr ){
10828 if( pCsr->aPage[iOff]!=0x02 && pCsr->aPage[iOff]!=0x05 ){
10829 pCsr->iCell = pCsr->nCell;
10830 }
10831 pCsr->iCell++;
10832 if( pCsr->iCell>=pCsr->nCell ){
10833 sqlite3_free(pCsr->aPage);
10834 pCsr->aPage = 0;
10835 if( pCsr->bOnePage ) return SQLITE_OK;
10836 pCsr->iPgno++;
10837 }else{
10838 return SQLITE_OK;
10839 }
10840 }else{
10841 /* If there is no record loaded, load it now. */
10842 if( pCsr->pRec==0 ){
10843 int bHasRowid = 0;
10844 int nPointer = 0;
10845 sqlite3_int64 nPayload = 0;
10846 sqlite3_int64 nHdr = 0;
10847 int iHdr;
10848 int U, X;
10849 int nLocal;
10850
10851 switch( pCsr->aPage[iOff] ){
10852 case 0x02:
10853 nPointer = 4;
10854 break;
10855 case 0x0a:
10856 break;
10857 case 0x0d:
10858 bHasRowid = 1;
10859 break;
10860 default:
10861 /* This is not a b-tree page with records on it. Continue. */
10862 pCsr->iCell = pCsr->nCell;

Callers 1

dbdataFilterFunction · 0.85

Calls 5

dbdataLoadPageFunction · 0.85
get_uint16Function · 0.85
dbdataGetVarintFunction · 0.85
get_uint32Function · 0.85
dbdataValueBytesFunction · 0.85

Tested by

no test coverage detected