Lines Matching refs:pPg
393 static void page_add_to_ckpt_list(PgHdr *pPg){ in page_add_to_ckpt_list() argument
394 Pager *pPager = pPg->pPager; in page_add_to_ckpt_list()
395 if( pPg->inCkpt ) return; in page_add_to_ckpt_list()
396 assert( pPg->pPrevCkpt==0 && pPg->pNextCkpt==0 ); in page_add_to_ckpt_list()
397 pPg->pPrevCkpt = 0; in page_add_to_ckpt_list()
399 pPager->pCkpt->pPrevCkpt = pPg; in page_add_to_ckpt_list()
401 pPg->pNextCkpt = pPager->pCkpt; in page_add_to_ckpt_list()
402 pPager->pCkpt = pPg; in page_add_to_ckpt_list()
403 pPg->inCkpt = 1; in page_add_to_ckpt_list()
405 static void page_remove_from_ckpt_list(PgHdr *pPg){ in page_remove_from_ckpt_list() argument
406 if( !pPg->inCkpt ) return; in page_remove_from_ckpt_list()
407 if( pPg->pPrevCkpt ){ in page_remove_from_ckpt_list()
408 assert( pPg->pPrevCkpt->pNextCkpt==pPg ); in page_remove_from_ckpt_list()
409 pPg->pPrevCkpt->pNextCkpt = pPg->pNextCkpt; in page_remove_from_ckpt_list()
411 assert( pPg->pPager->pCkpt==pPg ); in page_remove_from_ckpt_list()
412 pPg->pPager->pCkpt = pPg->pNextCkpt; in page_remove_from_ckpt_list()
414 if( pPg->pNextCkpt ){ in page_remove_from_ckpt_list()
415 assert( pPg->pNextCkpt->pPrevCkpt==pPg ); in page_remove_from_ckpt_list()
416 pPg->pNextCkpt->pPrevCkpt = pPg->pPrevCkpt; in page_remove_from_ckpt_list()
418 pPg->pNextCkpt = 0; in page_remove_from_ckpt_list()
419 pPg->pPrevCkpt = 0; in page_remove_from_ckpt_list()
420 pPg->inCkpt = 0; in page_remove_from_ckpt_list()
442 PgHdr *pPg, *pNext; in pager_reset() local
443 for(pPg=pPager->pAll; pPg; pPg=pNext){ in pager_reset()
444 pNext = pPg->pNextAll; in pager_reset()
445 sqliteFree(pPg); in pager_reset()
475 PgHdr *pPg; in pager_unwritelock() local
488 for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ in pager_unwritelock()
489 pPg->inJournal = 0; in pager_unwritelock()
490 pPg->dirty = 0; in pager_unwritelock()
491 pPg->needSync = 0; in pager_unwritelock()
530 PgHdr *pPg; /* An existing page in the cache */ in pager_playback_one_page() local
561 pPg = pager_lookup(pPager, pgRec.pgno); in pager_playback_one_page()
565 if( pPg ){ in pager_playback_one_page()
570 assert( pPg->nRef==0 || pPg->pgno==1 ); in pager_playback_one_page()
571 memcpy(PGHDR_TO_DATA(pPg), pgRec.aData, SQLITE_PAGE_SIZE); in pager_playback_one_page()
572 memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); in pager_playback_one_page()
573 pPg->dirty = 0; in pager_playback_one_page()
574 pPg->needSync = 0; in pager_playback_one_page()
575 CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); in pager_playback_one_page()
728 PgHdr *pPg; in pager_playback() local
729 for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ in pager_playback()
731 if( !pPg->dirty ) continue; in pager_playback()
732 if( (int)pPg->pgno <= pPager->origDbSize ){ in pager_playback()
733 sqliteOsSeek(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1)); in pager_playback()
735 TRACE2("REFETCH %d\n", pPg->pgno); in pager_playback()
736 CODEC(pPager, zBuf, pPg->pgno, 2); in pager_playback()
741 if( pPg->nRef==0 || memcmp(zBuf, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE) ){ in pager_playback()
742 memcpy(PGHDR_TO_DATA(pPg), zBuf, SQLITE_PAGE_SIZE); in pager_playback()
743 memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); in pager_playback()
745 pPg->needSync = 0; in pager_playback()
746 pPg->dirty = 0; in pager_playback()
1068 PgHdr *pPg, *pNext; in sqlitepager_close() local
1085 for(pPg=pPager->pAll; pPg; pPg=pNext){ in sqlitepager_close()
1086 pNext = pPg->pNextAll; in sqlitepager_close()
1087 sqliteFree(pPg); in sqlitepager_close()
1121 static void _page_ref(PgHdr *pPg){ in _page_ref() argument
1122 if( pPg->nRef==0 ){ in _page_ref()
1124 if( pPg==pPg->pPager->pFirstSynced ){ in _page_ref()
1125 PgHdr *p = pPg->pNextFree; in _page_ref()
1127 pPg->pPager->pFirstSynced = p; in _page_ref()
1129 if( pPg->pPrevFree ){ in _page_ref()
1130 pPg->pPrevFree->pNextFree = pPg->pNextFree; in _page_ref()
1132 pPg->pPager->pFirst = pPg->pNextFree; in _page_ref()
1134 if( pPg->pNextFree ){ in _page_ref()
1135 pPg->pNextFree->pPrevFree = pPg->pPrevFree; in _page_ref()
1137 pPg->pPager->pLast = pPg->pPrevFree; in _page_ref()
1139 pPg->pPager->nRef++; in _page_ref()
1141 pPg->nRef++; in _page_ref()
1142 REFINFO(pPg); in _page_ref()
1150 PgHdr *pPg = DATA_TO_PGHDR(pData); in sqlitepager_ref() local
1151 page_ref(pPg); in sqlitepager_ref()
1176 PgHdr *pPg; in syncJournal() local
1224 for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ in syncJournal()
1225 pPg->needSync = 0; in syncJournal()
1236 for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ in syncJournal()
1237 assert( pPg->needSync==0 ); in syncJournal()
1312 PgHdr *pPg; in sqlitepager_get() local
1376 pPg = 0; in sqlitepager_get()
1379 pPg = pager_lookup(pPager, pgno); in sqlitepager_get()
1381 if( pPg==0 ){ in sqlitepager_get()
1387 pPg = sqliteMallocRaw( sizeof(*pPg) + SQLITE_PAGE_SIZE in sqlitepager_get()
1389 if( pPg==0 ){ in sqlitepager_get()
1394 memset(pPg, 0, sizeof(*pPg)); in sqlitepager_get()
1395 pPg->pPager = pPager; in sqlitepager_get()
1396 pPg->pNextAll = pPager->pAll; in sqlitepager_get()
1398 pPager->pAll->pPrevAll = pPg; in sqlitepager_get()
1400 pPg->pPrevAll = 0; in sqlitepager_get()
1401 pPager->pAll = pPg; in sqlitepager_get()
1407 pPg = pPager->pFirstSynced; in sqlitepager_get()
1414 if( pPg==0 ){ in sqlitepager_get()
1420 pPg = pPager->pFirst; in sqlitepager_get()
1422 assert( pPg->nRef==0 ); in sqlitepager_get()
1426 if( pPg->dirty ){ in sqlitepager_get()
1427 assert( pPg->needSync==0 ); in sqlitepager_get()
1428 pPg->pDirty = 0; in sqlitepager_get()
1429 rc = pager_write_pagelist( pPg ); in sqlitepager_get()
1435 assert( pPg->dirty==0 ); in sqlitepager_get()
1445 if( pPg->alwaysRollback ){ in sqlitepager_get()
1451 if( pPg==pPager->pFirstSynced ){ in sqlitepager_get()
1452 PgHdr *p = pPg->pNextFree; in sqlitepager_get()
1456 if( pPg->pPrevFree ){ in sqlitepager_get()
1457 pPg->pPrevFree->pNextFree = pPg->pNextFree; in sqlitepager_get()
1459 assert( pPager->pFirst==pPg ); in sqlitepager_get()
1460 pPager->pFirst = pPg->pNextFree; in sqlitepager_get()
1462 if( pPg->pNextFree ){ in sqlitepager_get()
1463 pPg->pNextFree->pPrevFree = pPg->pPrevFree; in sqlitepager_get()
1465 assert( pPager->pLast==pPg ); in sqlitepager_get()
1466 pPager->pLast = pPg->pPrevFree; in sqlitepager_get()
1468 pPg->pNextFree = pPg->pPrevFree = 0; in sqlitepager_get()
1469 if( pPg->pNextHash ){ in sqlitepager_get()
1470 pPg->pNextHash->pPrevHash = pPg->pPrevHash; in sqlitepager_get()
1472 if( pPg->pPrevHash ){ in sqlitepager_get()
1473 pPg->pPrevHash->pNextHash = pPg->pNextHash; in sqlitepager_get()
1475 h = pager_hash(pPg->pgno); in sqlitepager_get()
1476 assert( pPager->aHash[h]==pPg ); in sqlitepager_get()
1477 pPager->aHash[h] = pPg->pNextHash; in sqlitepager_get()
1479 pPg->pNextHash = pPg->pPrevHash = 0; in sqlitepager_get()
1482 pPg->pgno = pgno; in sqlitepager_get()
1486 pPg->inJournal = (pPager->aInJournal[pgno/8] & (1<<(pgno&7)))!=0; in sqlitepager_get()
1487 pPg->needSync = 0; in sqlitepager_get()
1489 pPg->inJournal = 0; in sqlitepager_get()
1490 pPg->needSync = 0; in sqlitepager_get()
1494 page_add_to_ckpt_list(pPg); in sqlitepager_get()
1496 page_remove_from_ckpt_list(pPg); in sqlitepager_get()
1498 pPg->dirty = 0; in sqlitepager_get()
1499 pPg->nRef = 1; in sqlitepager_get()
1500 REFINFO(pPg); in sqlitepager_get()
1503 pPg->pNextHash = pPager->aHash[h]; in sqlitepager_get()
1504 pPager->aHash[h] = pPg; in sqlitepager_get()
1505 if( pPg->pNextHash ){ in sqlitepager_get()
1506 assert( pPg->pNextHash->pPrevHash==0 ); in sqlitepager_get()
1507 pPg->pNextHash->pPrevHash = pPg; in sqlitepager_get()
1510 memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); in sqlitepager_get()
1514 sqlitepager_unref(PGHDR_TO_DATA(pPg)); in sqlitepager_get()
1519 memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE); in sqlitepager_get()
1523 rc = sqliteOsRead(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE); in sqlitepager_get()
1524 TRACE2("FETCH %d\n", pPg->pgno); in sqlitepager_get()
1525 CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); in sqlitepager_get()
1530 sqlitepager_unref(PGHDR_TO_DATA(pPg)); in sqlitepager_get()
1533 memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE); in sqlitepager_get()
1540 page_ref(pPg); in sqlitepager_get()
1542 *ppPage = PGHDR_TO_DATA(pPg); in sqlitepager_get()
1558 PgHdr *pPg; in sqlitepager_lookup() local
1569 pPg = pager_lookup(pPager, pgno); in sqlitepager_lookup()
1570 if( pPg==0 ) return 0; in sqlitepager_lookup()
1571 page_ref(pPg); in sqlitepager_lookup()
1572 return PGHDR_TO_DATA(pPg); in sqlitepager_lookup()
1584 PgHdr *pPg; in sqlitepager_unref() local
1588 pPg = DATA_TO_PGHDR(pData); in sqlitepager_unref()
1589 assert( pPg->nRef>0 ); in sqlitepager_unref()
1590 pPg->nRef--; in sqlitepager_unref()
1591 REFINFO(pPg); in sqlitepager_unref()
1596 if( pPg->nRef==0 ){ in sqlitepager_unref()
1598 pPager = pPg->pPager; in sqlitepager_unref()
1599 pPg->pNextFree = 0; in sqlitepager_unref()
1600 pPg->pPrevFree = pPager->pLast; in sqlitepager_unref()
1601 pPager->pLast = pPg; in sqlitepager_unref()
1602 if( pPg->pPrevFree ){ in sqlitepager_unref()
1603 pPg->pPrevFree->pNextFree = pPg; in sqlitepager_unref()
1605 pPager->pFirst = pPg; in sqlitepager_unref()
1607 if( pPg->needSync==0 && pPager->pFirstSynced==0 ){ in sqlitepager_unref()
1608 pPager->pFirstSynced = pPg; in sqlitepager_unref()
1715 PgHdr *pPg = DATA_TO_PGHDR(pData); in sqlitepager_begin() local
1716 Pager *pPager = pPg->pPager; in sqlitepager_begin()
1718 assert( pPg->nRef>0 ); in sqlitepager_begin()
1754 PgHdr *pPg = DATA_TO_PGHDR(pData); in sqlitepager_write() local
1755 Pager *pPager = pPg->pPager; in sqlitepager_write()
1770 pPg->dirty = 1; in sqlitepager_write()
1771 if( pPg->inJournal && (pPg->inCkpt || pPager->ckptInUse==0) ){ in sqlitepager_write()
1800 if( !pPg->inJournal && pPager->useJournal ){ in sqlitepager_write()
1801 if( (int)pPg->pgno <= pPager->origDbSize ){ in sqlitepager_write()
1805 u32 cksum = pager_cksum(pPager, pPg->pgno, pData); in sqlitepager_write()
1806 saved = *(u32*)PGHDR_TO_EXTRA(pPg); in sqlitepager_write()
1807 store32bits(cksum, pPg, SQLITE_PAGE_SIZE); in sqlitepager_write()
1812 store32bits(pPg->pgno, pPg, -4); in sqlitepager_write()
1813 CODEC(pPager, pData, pPg->pgno, 7); in sqlitepager_write()
1815 TRACE3("JOURNAL %d %d\n", pPg->pgno, pPg->needSync); in sqlitepager_write()
1816 CODEC(pPager, pData, pPg->pgno, 0); in sqlitepager_write()
1818 *(u32*)PGHDR_TO_EXTRA(pPg) = saved; in sqlitepager_write()
1827 pPager->aInJournal[pPg->pgno/8] |= 1<<(pPg->pgno&7); in sqlitepager_write()
1828 pPg->needSync = !pPager->noSync; in sqlitepager_write()
1829 pPg->inJournal = 1; in sqlitepager_write()
1831 pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); in sqlitepager_write()
1832 page_add_to_ckpt_list(pPg); in sqlitepager_write()
1835 pPg->needSync = !pPager->journalStarted && !pPager->noSync; in sqlitepager_write()
1836 TRACE3("APPEND %d %d\n", pPg->pgno, pPg->needSync); in sqlitepager_write()
1838 if( pPg->needSync ){ in sqlitepager_write()
1848 if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){ in sqlitepager_write()
1849 assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize ); in sqlitepager_write()
1850 store32bits(pPg->pgno, pPg, -4); in sqlitepager_write()
1851 CODEC(pPager, pData, pPg->pgno, 7); in sqlitepager_write()
1853 TRACE2("CKPT-JOURNAL %d\n", pPg->pgno); in sqlitepager_write()
1854 CODEC(pPager, pData, pPg->pgno, 0); in sqlitepager_write()
1862 pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); in sqlitepager_write()
1863 page_add_to_ckpt_list(pPg); in sqlitepager_write()
1868 if( pPager->dbSize<(int)pPg->pgno ){ in sqlitepager_write()
1869 pPager->dbSize = pPg->pgno; in sqlitepager_write()
1880 PgHdr *pPg = DATA_TO_PGHDR(pData); in sqlitepager_iswriteable() local
1881 return pPg->dirty; in sqlitepager_iswriteable()
1928 PgHdr *pPg; in sqlitepager_dont_write() local
1930 pPg = pager_lookup(pPager, pgno); in sqlitepager_dont_write()
1931 pPg->alwaysRollback = 1; in sqlitepager_dont_write()
1932 if( pPg && pPg->dirty && !pPager->ckptInUse ){ in sqlitepager_dont_write()
1933 if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSize<pPager->dbSize ){ in sqlitepager_dont_write()
1944 pPg->dirty = 0; in sqlitepager_dont_write()
1956 PgHdr *pPg = DATA_TO_PGHDR(pData); in sqlitepager_dont_rollback() local
1957 Pager *pPager = pPg->pPager; in sqlitepager_dont_rollback()
1960 if( pPg->alwaysRollback || pPager->alwaysRollback ) return; in sqlitepager_dont_rollback()
1961 if( !pPg->inJournal && (int)pPg->pgno <= pPager->origDbSize ){ in sqlitepager_dont_rollback()
1963 pPager->aInJournal[pPg->pgno/8] |= 1<<(pPg->pgno&7); in sqlitepager_dont_rollback()
1964 pPg->inJournal = 1; in sqlitepager_dont_rollback()
1966 pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); in sqlitepager_dont_rollback()
1967 page_add_to_ckpt_list(pPg); in sqlitepager_dont_rollback()
1969 TRACE2("DONT_ROLLBACK %d\n", pPg->pgno); in sqlitepager_dont_rollback()
1971 if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){ in sqlitepager_dont_rollback()
1972 assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize ); in sqlitepager_dont_rollback()
1974 pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); in sqlitepager_dont_rollback()
1975 page_add_to_ckpt_list(pPg); in sqlitepager_dont_rollback()
1988 PgHdr *pPg; in sqlitepager_commit() local
2018 pPg = pager_get_all_dirty_pages(pPager); in sqlitepager_commit()
2019 if( pPg ){ in sqlitepager_commit()
2020 rc = pager_write_pagelist(pPg); in sqlitepager_commit()
2155 PgHdr *pPg, *pNext; in sqlitepager_ckpt_commit() local
2162 for(pPg=pPager->pCkpt; pPg; pPg=pNext){ in sqlitepager_ckpt_commit()
2163 pNext = pPg->pNextCkpt; in sqlitepager_ckpt_commit()
2164 assert( pPg->inCkpt ); in sqlitepager_ckpt_commit()
2165 pPg->inCkpt = 0; in sqlitepager_ckpt_commit()
2166 pPg->pPrevCkpt = pPg->pNextCkpt = 0; in sqlitepager_ckpt_commit()
2213 PgHdr *pPg; in sqlitepager_refdump() local
2214 for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){ in sqlitepager_refdump()
2215 if( pPg->nRef<=0 ) continue; in sqlitepager_refdump()
2217 pPg->pgno, (int)PGHDR_TO_DATA(pPg), pPg->nRef); in sqlitepager_refdump()