Example #1
0
 /*
 ** External API function used to create a new virtual-table module.
 */
 static int sqlite3_create_module(
     sqlite3 db,             /* Database in which module is registered */
     string zName,           /* Name assigned to this module */
     sqlite3_module pModule, /* The definition of the module */
     object pAux             /* Context pointer for xCreate/xConnect */
     )
 {
     return(createModule(db, zName, pModule, pAux, null));
 }
Example #2
0
 /*
 ** External API function used to create a new virtual-table module.
 */
 static int sqlite3_create_module_v2(
     sqlite3 db,             /* Database in which module is registered */
     string zName,           /* Name assigned to this module */
     sqlite3_module pModule, /* The definition of the module */
     sqlite3_vtab pAux,      /* Context pointer for xCreate/xConnect */
     smdxDestroy xDestroy    /* Module destructor function */
     )
 {
     return(createModule(db, zName, pModule, pAux, xDestroy));
 }
Example #3
0
        /*
        ** The actual function that does the work of creating a new module.
        ** This function implements the sqlite3_create_module() and
        ** sqlite3_create_module_v2() interfaces.
        */
        static int createModule(
            sqlite3 db,             /* Database in which module is registered */
            string zName,           /* Name assigned to this module */
            sqlite3_module pModule, /* The definition of the module */
            object pAux,            /* Context pointer for xCreate/xConnect */
            smdxDestroy xDestroy    /* Module destructor function */
            )
        {
            int    rc, nName;
            Module pMod;

            sqlite3_mutex_enter(db.mutex);
            nName = sqlite3Strlen30(zName);
            pMod  = new Module();//  (Module)sqlite3DbMallocRaw( db, sizeof( Module ) + nName + 1 );
            if (pMod != null)
            {
                Module pDel;
                string zCopy;          // = (char )(&pMod[1]);
                zCopy         = zName; //memcpy(zCopy, zName, nName+1);
                pMod.zName    = zCopy;
                pMod.pModule  = pModule;
                pMod.pAux     = pAux;
                pMod.xDestroy = xDestroy;
                pDel          = (Module)sqlite3HashInsert(ref db.aModule, zCopy, nName, pMod);
                if (pDel != null && pDel.xDestroy != null)
                {
                    sqlite3ResetInternalSchema(db, -1);
                    pDel.xDestroy(ref pDel.pAux);
                }
                sqlite3DbFree(db, ref pDel);
                //if( pDel==pMod ){
                //  db.mallocFailed = 1;
                //}
            }
            else if (xDestroy != null)
            {
                xDestroy(ref pAux);
            }
            rc = sqlite3ApiExit(db, SQLITE_OK);
            sqlite3_mutex_leave(db.mutex);
            return(rc);
        }
Example #4
0
    /*
    ** The actual function that does the work of creating a new module.
    ** This function implements the sqlite3_create_module() and
    ** sqlite3_create_module_v2() interfaces.
    */
    static int createModule(
      sqlite3 db,              /* Database in which module is registered */
      string zName,            /* Name assigned to this module */
      sqlite3_module pModule,  /* The definition of the module */
      object pAux,             /* Context pointer for xCreate/xConnect */
      smdxDestroy xDestroy     /* Module destructor function */
    )
    {
      int rc, nName;
      Module pMod;

      sqlite3_mutex_enter( db.mutex );
      nName = sqlite3Strlen30( zName );
      pMod = new Module();//  (Module)sqlite3DbMallocRaw( db, sizeof( Module ) + nName + 1 );
      if ( pMod != null )
      {
        Module pDel;
        string zCopy;// = (char )(&pMod[1]);
        zCopy = zName;//memcpy(zCopy, zName, nName+1);
        pMod.zName = zCopy;
        pMod.pModule = pModule;
        pMod.pAux = pAux;
        pMod.xDestroy = xDestroy;
        pDel = (Module)sqlite3HashInsert( ref db.aModule, zCopy, nName, pMod );
        if ( pDel != null && pDel.xDestroy != null )
        {
          sqlite3ResetInternalSchema( db, -1 );
          pDel.xDestroy( ref pDel.pAux );
        }
        sqlite3DbFree( db, ref pDel );
        //if( pDel==pMod ){
        //  db.mallocFailed = 1;
        //}
      }
      else if ( xDestroy != null )
      {
        xDestroy( ref pAux );
      }
      rc = sqlite3ApiExit( db, SQLITE_OK );
      sqlite3_mutex_leave( db.mutex );
      return rc;
    }
Example #5
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);
        }
Example #6
0
 /*
 ** External API function used to create a new virtual-table module.
 */
 static int sqlite3_create_module(
   sqlite3 db,               /* Database in which module is registered */
   string zName,             /* Name assigned to this module */
   sqlite3_module pModule,   /* The definition of the module */
   object pAux               /* Context pointer for xCreate/xConnect */
 )
 {
   return createModule( db, zName, pModule, pAux, null );
 }
Example #7
0
 /*
 ** External API function used to create a new virtual-table module.
 */
 static int sqlite3_create_module_v2(
   sqlite3 db,               /* Database in which module is registered */
   string zName,             /* Name assigned to this module */
   sqlite3_module pModule,   /* The definition of the module */
   sqlite3_vtab pAux,        /* Context pointer for xCreate/xConnect */
   smdxDestroy xDestroy      /* Module destructor function */
 )
 {
   return createModule( db, zName, pModule, pAux, xDestroy );
 }
 internal static extern IntPtr sqlite3_create_disposable_module(IntPtr db, IntPtr name, ref sqlite3_module module, IntPtr pClientData, xDestroyModule xDestroy);