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


C# sqlite3.xCommitCallback方法代码示例

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


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

示例1: vdbeCommit

    /*
    ** A read or write transaction may or may not be active on database handle
    ** db. If a transaction is active, commit it. If there is a
    ** write-transaction spanning more than one database file, this routine
    ** takes care of the master journal trickery.
    */
    static int vdbeCommit( sqlite3 db, Vdbe p )
    {
      int i;
      int nTrans = 0;  /* Number of databases with an active write-transaction */
      int rc = SQLITE_OK;
      bool needXcommit = false;

#if SQLITE_OMIT_VIRTUALTABLE
      /* With this option, sqlite3VtabSync() is defined to be simply
** SQLITE_OK so p is not used.
*/
      UNUSED_PARAMETER( p );
#endif
      /* Before doing anything else, call the xSync() callback for any
** virtual module tables written in this transaction. This has to
** be done before determining whether a master journal file is
** required, as an xSync() callback may add an attached database
** to the transaction.
*/
      rc = sqlite3VtabSync( db, ref p.zErrMsg );

      /* This loop determines (a) if the commit hook should be invoked and
      ** (b) how many database files have open write transactions, not
      ** including the temp database. (b) is important because if more than
      ** one database file has an open write transaction, a master journal
      ** file is required for an atomic commit.
      */
      for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ )
      {
        Btree pBt = db.aDb[i].pBt;
        if ( sqlite3BtreeIsInTrans( pBt ) )
        {
          needXcommit = true;
          if ( i != 1 )
            nTrans++;
          rc = sqlite3PagerExclusiveLock( sqlite3BtreePager( pBt ) );
        }
      }
      if ( rc != SQLITE_OK )
      {
        return rc;
      }

      /* If there are any write-transactions at all, invoke the commit hook */
      if ( needXcommit && db.xCommitCallback != null )
      {
        rc = db.xCommitCallback( db.pCommitArg );
        if ( rc != 0 )
        {
          return SQLITE_CONSTRAINT;
        }
      }

      /* The simple case - no more than one database file (not counting the
      ** TEMP database) has a transaction active.   There is no need for the
      ** master-journal.
      **
      ** If the return value of sqlite3BtreeGetFilename() is a zero length
      ** string, it means the main database is :memory: or a temp file.  In
      ** that case we do not support atomic multi-file commits, so use the
      ** simple case then too.
      */
      if ( 0 == sqlite3Strlen30( sqlite3BtreeGetFilename( db.aDb[0].pBt ) )
      || nTrans <= 1 )
      {
        for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ )
        {
          Btree pBt = db.aDb[i].pBt;
          if ( pBt != null )
          {
            rc = sqlite3BtreeCommitPhaseOne( pBt, null );
          }
        }

        /* Do the commit only if all databases successfully complete phase 1.
        ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
        ** IO error while deleting or truncating a journal file. It is unlikely,
        ** but could happen. In this case abandon processing and return the error.
        */
        for ( i = 0; rc == SQLITE_OK && i < db.nDb; i++ )
        {
          Btree pBt = db.aDb[i].pBt;
          if ( pBt != null )
          {
            rc = sqlite3BtreeCommitPhaseTwo( pBt, 0 );
          }
        }
        if ( rc == SQLITE_OK )
        {
          sqlite3VtabCommit( db );
        }
      }

      /* The complex case - There is a multi-file write-transaction active.
//.........这里部分代码省略.........
开发者ID:jdhardy,项目名称:ironpython,代码行数:101,代码来源:vdbeaux_c.cs


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