当前位置: 首页>>代码示例>>C#>>正文


C# Pager.xReiniter方法代码示例

本文整理汇总了C#中Community.CsharpSqlite.Pager.xReiniter方法的典型用法代码示例。如果您正苦于以下问题:C# Pager.xReiniter方法的具体用法?C# Pager.xReiniter怎么用?C# Pager.xReiniter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Community.CsharpSqlite.Pager的用法示例。


在下文中一共展示了Pager.xReiniter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: pager_playback_one_page


//.........这里部分代码省略.........

      PAGERTRACE( "PLAYBACK %d page %d hash(%08x) %s\n",
      PAGERID( pPager ), pgno, pager_datahash( pPager.pageSize, aData ),
      ( isMainJrnl != 0 ? "main-journal" : "sub-journal" )
      );
      if ( ( pPager.state >= PAGER_EXCLUSIVE )
      && ( pPg == null || 0 == ( pPg.flags & PGHDR_NEED_SYNC ) )
      && isOpen( pPager.fd )
      && 0 == isUnsync
      )
      {
        i64 ofst = ( pgno - 1 ) * (i64)pPager.pageSize;
        rc = sqlite3OsWrite( pPager.fd, (u8[])aData, pPager.pageSize, ofst );
        if ( pgno > pPager.dbFileSize )
        {
          pPager.dbFileSize = (u32)pgno;
        }
        if ( pPager.pBackup != null )
        {
          if ( CODEC1( pPager, aData, pgno, SQLITE_DECRYPT ) ) rc = SQLITE_NOMEM; // CODEC1( pPager, aData, pgno, 3, rc = SQLITE_NOMEM );
          sqlite3BackupUpdate( pPager.pBackup, pgno, (u8[])aData );
          if ( CODEC2( pPager, aData, pgno, SQLITE_ENCRYPT_READ_CTX,ref aData ) ) rc = SQLITE_NOMEM;//CODEC2( pPager, aData, pgno, 7, rc = SQLITE_NOMEM, aData);
        }
      }
      else if ( 0 == isMainJrnl && pPg == null )
      {
        /* If this is a rollback of a savepoint and data was not written to
        ** the database and the page is not in-memory, there is a potential
        ** problem. When the page is next fetched by the b-tree layer, it
        ** will be read from the database file, which may or may not be
        ** current.
        **
        ** There are a couple of different ways this can happen. All are quite
        ** obscure. When running in synchronous mode, this can only happen
        ** if the page is on the free-list at the start of the transaction, then
        ** populated, then moved using sqlite3PagerMovepage().
        **
        ** The solution is to add an in-memory page to the cache containing
        ** the data just read from the sub-journal. Mark the page as dirty
        ** and if the pager requires a journal-sync, then mark the page as
        ** requiring a journal-sync before it is written.
        */
        Debug.Assert( isSavepnt != 0 );
        if ( ( rc = sqlite3PagerAcquire( pPager, (u32)pgno, ref pPg, 1 ) ) != SQLITE_OK )
        {
          return rc;
        }
        pPg.flags &= ~PGHDR_NEED_READ;
        sqlite3PcacheMakeDirty( pPg );
      }
      if ( pPg != null )
      {
        /* No page should ever be explicitly rolled back that is in use, except
        ** for page 1 which is held in use in order to keep the lock on the
        ** database active. However such a page may be rolled back as a result
        ** of an internal error resulting in an automatic call to
        ** sqlite3PagerRollback().
        */
        byte[] pData = pPg.pData;
        Buffer.BlockCopy( aData, 0, pData, 0, pPager.pageSize );// memcpy(pData, (u8[])aData, pPager.pageSize);
        pPager.xReiniter( pPg );
        if ( isMainJrnl != 0 && ( 0 == isSavepnt || pOffset <= pPager.journalHdr ) )
        {
          /* If the contents of this page were just restored from the main
          ** journal file, then its content must be as they were when the
          ** transaction was first opened. In this case we can mark the page
          ** as clean, since there will be no need to write it out to the.
          **
          ** There is one exception to this rule. If the page is being rolled
          ** back as part of a savepoint (or statement) rollback from an
          ** unsynced portion of the main journal file, then it is not safe
          ** to mark the page as clean. This is because marking the page as
          ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is
          ** already in the journal file (recorded in Pager.pInJournal) and
          ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to
          ** again within this transaction, it will be marked as dirty but
          ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially
          ** be written out into the database file before its journal file
          ** segment is synced. If a crash occurs during or following this,
          ** database corruption may ensue.
          */

          sqlite3PcacheMakeClean( pPg );
        }
#if SQLITE_CHECK_PAGES
pPg.pageHash = pager_pagehash(pPg);
#endif
        /* If this was page 1, then restore the value of Pager.dbFileVers.
** Do this before any decoding. */
        if ( pgno == 1 )
        {
          Buffer.BlockCopy( pData, 24, pPager.dbFileVers, 0, pPager.dbFileVers.Length ); //memcpy(pPager.dbFileVers, ((u8*)pData)[24], sizeof(pPager.dbFileVers));
        }

        /* Decode the page just read from disk */
        if ( CODEC1( pPager, pData, pPg.pgno, SQLITE_DECRYPT ) ) rc = SQLITE_NOMEM; //CODEC1(pPager, pData, pPg.pgno, 3, rc=SQLITE_NOMEM);
        sqlite3PcacheRelease( pPg );
      }
      return rc;
    }
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:pager_c.cs


注:本文中的Community.CsharpSqlite.Pager.xReiniter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。