Exemple #1
0
        /*
        ** Invoke either the xSavepoint, xRollbackTo or xRelease method of all
        ** virtual tables that currently have an open transaction. Pass iSavepoint
        ** as the second argument to the virtual table method invoked.
        **
        ** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is
        ** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is
        ** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with
        ** an open transaction is invoked.
        **
        ** If any virtual table method returns an error code other than SQLITE_OK,
        ** processing is abandoned and the error returned to the caller of this
        ** function immediately. If all calls to virtual table methods are successful,
        ** SQLITE_OK is returned.
        */
        static int sqlite3VtabSavepoint(sqlite3 db, int op, int iSavepoint)
        {
            int rc = SQLITE_OK;

            Debug.Assert(op == SAVEPOINT_RELEASE || op == SAVEPOINT_ROLLBACK || op == SAVEPOINT_BEGIN);
            Debug.Assert(iSavepoint >= 0);
            if (db.aVTrans != null)
            {
                int i;
                for (i = 0; rc == SQLITE_OK && i < db.nVTrans; i++)
                {
                    VTable         pVTab = db.aVTrans[i];
                    sqlite3_module pMod  = pVTab.pMod.pModule;
                    if (pMod.iVersion >= 2)
                    {
                        smdxFunctionArg xMethod = null; //int (*xMethod)(sqlite3_vtab *, int);
                        switch (op)
                        {
                        case SAVEPOINT_BEGIN:
                            xMethod          = pMod.xSavepoint;
                            pVTab.iSavepoint = iSavepoint + 1;
                            break;

                        case SAVEPOINT_ROLLBACK:
                            xMethod = pMod.xRollbackTo;
                            break;

                        default:
                            xMethod = pMod.xRelease;
                            break;
                        }
                        if (xMethod != null && pVTab.iSavepoint > iSavepoint)
                        {
                            rc = xMethod(db.aVTrans[i].pVtab, iSavepoint);
                        }
                    }
                }
            }
            return(rc);
        }
Exemple #2
0
     //Version 2
     public     sqlite3_module(
      int iVersion,
      smdxCreateConnect xCreate,
      smdxCreateConnect xConnect,
      smdxBestIndex xBestIndex,
      smdxDisconnect xDisconnect,
      smdxDestroy xDestroy,
      smdxOpen xOpen,
      smdxClose xClose,
      smdxFilter xFilter,
      smdxNext xNext,
      smdxEof xEof,
      smdxColumn xColumn,
      smdxRowid xRowid,
      smdxUpdate xUpdate,
      smdxFunction xBegin,
      smdxFunction xSync,
      smdxFunction xCommit,
      smdxFunction xRollback,
      smdxFindFunction xFindFunction,
      smdxRename xRename,
 /* The methods above are in version 1 of the sqlite_module object. Those 
 ** below are for version 2 and greater. */
      smdxFunctionArg xSavepoint,
      smdxFunctionArg xRelease,
      smdxFunctionArg xRollbackTo
     )
     {
       this.iVersion = iVersion;
       this.xCreate = xCreate;
       this.xConnect = xConnect;
       this.xBestIndex = xBestIndex;
       this.xDisconnect = xDisconnect;
       this.xDestroy = xDestroy;
       this.xOpen = xOpen;
       this.xClose = xClose;
       this.xFilter = xFilter;
       this.xNext = xNext;
       this.xEof = xEof;
       this.xColumn = xColumn;
       this.xRowid = xRowid;
       this.xUpdate = xUpdate;
       this.xBegin = xBegin;
       this.xSync = xSync;
       this.xCommit = xCommit;
       this.xRollback = xRollback;
       this.xFindFunction = xFindFunction;
       this.xRename = xRename;
       this.xSavepoint = xSavepoint;
       this.xRelease = xRelease;
       this.xRollbackTo = xRollbackTo;
     }