Example #1
0
        internal static void copyNodeContent(MemPage pFrom, MemPage pTo, ref RC pRC)
        {
            if (pRC != RC.OK)
            {
                return;
            }
            var pBt      = pFrom.Shared;
            var aFrom    = pFrom.Data;
            var aTo      = pTo.Data;
            var iFromHdr = pFrom.HeaderOffset;
            var iToHdr   = (pTo.ID == 1 ? 100 : 0);

            Debug.Assert(pFrom.HasInit);
            Debug.Assert(pFrom.FreeBytes >= iToHdr);
            Debug.Assert(ConvertEx.Get2(aFrom, iFromHdr + 5) <= (int)pBt.UsableSize);
            // Copy the b-tree node content from page pFrom to page pTo.
            var iData = (int)ConvertEx.Get2(aFrom, iFromHdr + 5);

            Buffer.BlockCopy(aFrom, iData, aTo, iData, (int)pBt.UsableSize - iData);
            Buffer.BlockCopy(aFrom, iFromHdr, aTo, iToHdr, pFrom.CellOffset + 2 * pFrom.Cells);
            // Reinitialize page pTo so that the contents of the MemPage structure match the new data. The initialization of pTo can actually fail under
            // fairly obscure circumstances, even though it is a copy of initialized  page pFrom.
            pTo.HasInit = false;
            var rc = pTo.btreeInitPage();

            if (rc != RC.OK)
            {
                pRC = rc;
                return;
            }
            // If this is an auto-vacuum database, update the pointer-map entries for any b-tree or overflow pages that pTo now contains the pointers to.
#if !SQLITE_OMIT_AUTOVACUUM
            if (pBt.AutoVacuum)
#else
            if (false)
#endif
            {
                pRC = pTo.setChildPtrmaps();
            }
        }
Example #2
0
        internal RC getAndInitPage(Pgno pgno, ref MemPage ppPage)
        {
            Debug.Assert(MutexEx.Held(this.Mutex));
            RC rc;

            if (pgno > btreePagecount())
            {
                rc = SysEx.SQLITE_CORRUPT_BKPT();
            }
            else
            {
                rc = btreeGetPage(pgno, ref ppPage, 0);
                if (rc == RC.OK)
                {
                    rc = ppPage.btreeInitPage();
                    if (rc != RC.OK)
                    {
                        ppPage.releasePage();
                    }
                }
            }
            Debug.Assert(pgno != 0 || rc == RC.CORRUPT);
            return(rc);
        }
 internal RC getAndInitPage(Pgno pgno, ref MemPage ppPage)
 {
     Debug.Assert(MutexEx.Held(this.Mutex));
     RC rc;
     if (pgno > btreePagecount())
         rc = SysEx.SQLITE_CORRUPT_BKPT();
     else
     {
         rc = btreeGetPage(pgno, ref ppPage, 0);
         if (rc == RC.OK)
         {
             rc = ppPage.btreeInitPage();
             if (rc != RC.OK)
                 ppPage.releasePage();
         }
     }
     Debug.Assert(pgno != 0 || rc == RC.CORRUPT);
     return rc;
 }
Example #4
0
 internal static void copyNodeContent(MemPage pFrom, MemPage pTo, ref RC pRC)
 {
     if (pRC != RC.OK)
         return;
     var pBt = pFrom.Shared;
     var aFrom = pFrom.Data;
     var aTo = pTo.Data;
     var iFromHdr = pFrom.HeaderOffset;
     var iToHdr = (pTo.ID == 1 ? 100 : 0);
     Debug.Assert(pFrom.HasInit);
     Debug.Assert(pFrom.FreeBytes >= iToHdr);
     Debug.Assert(ConvertEx.Get2(aFrom, iFromHdr + 5) <= (int)pBt.UsableSize);
     // Copy the b-tree node content from page pFrom to page pTo.
     var iData = (int)ConvertEx.Get2(aFrom, iFromHdr + 5);
     Buffer.BlockCopy(aFrom, iData, aTo, iData, (int)pBt.UsableSize - iData);
     Buffer.BlockCopy(aFrom, iFromHdr, aTo, iToHdr, pFrom.CellOffset + 2 * pFrom.Cells);
     // Reinitialize page pTo so that the contents of the MemPage structure match the new data. The initialization of pTo can actually fail under
     // fairly obscure circumstances, even though it is a copy of initialized  page pFrom.
     pTo.HasInit = false;
     var rc = pTo.btreeInitPage();
     if (rc != RC.OK)
     {
         pRC = rc;
         return;
     }
     // If this is an auto-vacuum database, update the pointer-map entries for any b-tree or overflow pages that pTo now contains the pointers to.
     #if !SQLITE_OMIT_AUTOVACUUM
     if (pBt.AutoVacuum)
     #else
     if (false)
     #endif
     {
         pRC = pTo.setChildPtrmaps();
     }
 }