コード例 #1
0
ファイル: sqlite3_h.cs プロジェクト: hanahanaside/JPN
     //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;
     }
コード例 #2
0
ファイル: vtab_c.cs プロジェクト: z0rg1nc/CsharpSqliteFork
        /*
        ** Invoke a virtual table constructor (either xCreate or xConnect). The
        ** pointer to the function to invoke is passed as the fourth parameter
        ** to this procedure.
        */
        static int vtabCallConstructor(
            sqlite3 db,
            Table pTab,
            Module pMod,
            smdxCreateConnect xConstruct,
            ref string pzErr
            )
        {
            VtabCtx sCtx = new VtabCtx();
            VTable  pVTable;
            int     rc;

            string[] azArg       = pTab.azModuleArg;
            int      nArg        = pTab.nModuleArg;
            string   zErr        = null;
            string   zModuleName = sqlite3MPrintf(db, "%s", pTab.zName);

            //if ( String.IsNullOrEmpty( zModuleName ) )
            //{
            //  return SQLITE_NOMEM;
            //}

            pVTable = new VTable();//sqlite3DbMallocZero( db, sizeof( VTable ) );
            //if ( null == pVTable )
            //{
            //  sqlite3DbFree( db, ref zModuleName );
            //  return SQLITE_NOMEM;
            //}
            pVTable.db   = db;
            pVTable.pMod = pMod;

            /* Invoke the virtual table constructor */
            //assert( &db->pVtabCtx );
            Debug.Assert(xConstruct != null);
            sCtx.pTab    = pTab;
            sCtx.pVTable = pVTable;
            db.pVtabCtx  = sCtx;
            rc           = xConstruct(db, pMod.pAux, nArg, azArg, out pVTable.pVtab, out zErr);
            db.pVtabCtx  = null;
            //if ( rc == SQLITE_NOMEM )
            //  db.mallocFailed = 1;

            if (SQLITE_OK != rc)
            {
                if (zErr == "")
                {
                    pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
                }
                else
                {
                    pzErr = sqlite3MPrintf(db, "%s", zErr);
                    zErr  = null;//sqlite3_free( zErr );
                }
                sqlite3DbFree(db, ref pVTable);
            }
            else if (ALWAYS(pVTable.pVtab))
            {
                /* Justification of ALWAYS():  A correct vtab constructor must allocate
                ** the sqlite3_vtab object if successful.  */
                pVTable.pVtab.pModule = pMod.pModule;
                pVTable.nRef          = 1;
                if (sCtx.pTab != null)
                {
                    string zFormat = "vtable constructor did not declare schema: %s";
                    pzErr = sqlite3MPrintf(db, zFormat, pTab.zName);
                    sqlite3VtabUnlock(pVTable);
                    rc = SQLITE_ERROR;
                }
                else
                {
                    int iCol;

                    /* If everything went according to plan, link the new VTable structure
                    ** into the linked list headed by pTab->pVTable. Then loop through the
                    ** columns of the table to see if any of them contain the token "hidden".
                    ** If so, set the Column.isHidden flag and remove the token from
                    ** the type string.  */
                    pVTable.pNext = pTab.pVTable;
                    pTab.pVTable  = pVTable;

                    for (iCol = 0; iCol < pTab.nCol; iCol++)
                    {
                        if (String.IsNullOrEmpty(pTab.aCol[iCol].zType))
                        {
                            continue;
                        }
                        StringBuilder zType = new StringBuilder(pTab.aCol[iCol].zType);
                        int           nType;
                        int           i = 0;
                        //if ( zType )
                        //  continue;
                        nType = sqlite3Strlen30(zType);
                        if (sqlite3StrNICmp("hidden", 0, zType.ToString(), 6) != 0 || (zType.Length > 6 && zType[6] != ' '))
                        {
                            for (i = 0; i < nType; i++)
                            {
                                if ((0 == sqlite3StrNICmp(" hidden", zType.ToString().Substring(i), 7)) &&
                                    (i + 7 == zType.Length || (zType[i + 7] == '\0' || zType[i + 7] == ' '))
                                    )
                                {
                                    i++;
                                    break;
                                }
                            }
                        }
                        if (i < nType)
                        {
                            int j;
                            int nDel = 6 + (zType.Length > i + 6 ? 1 : 0);
                            for (j = i; (j + nDel) < nType; j++)
                            {
                                zType[j] = zType[j + nDel];
                            }
                            if (zType[i] == '\0' && i > 0)
                            {
                                Debug.Assert(zType[i - 1] == ' ');
                                zType.Length = i;//[i - 1] = '\0';
                            }
                            pTab.aCol[iCol].isHidden = 1;
                            pTab.aCol[iCol].zType    = zType.ToString().Substring(0, j);
                        }
                    }
                }
            }

            sqlite3DbFree(db, ref zModuleName);
            return(rc);
        }
コード例 #3
0
ファイル: sqlite3_h.cs プロジェクト: hanahanaside/JPN
 //Version 1
   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 )
   {
     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;
   }
コード例 #4
0
ファイル: vtab_c.cs プロジェクト: laboratoryyingong/BARLESS
    /*
    ** Invoke a virtual table constructor (either xCreate or xConnect). The
    ** pointer to the function to invoke is passed as the fourth parameter
    ** to this procedure.
    */
    static int vtabCallConstructor(
      sqlite3 db,
      Table pTab,
      Module pMod,
      smdxCreateConnect xConstruct,
      ref string pzErr
    )
    {
      VtabCtx sCtx = new VtabCtx();
      VTable pVTable;
      int rc;
      string[] azArg = pTab.azModuleArg;
      int nArg = pTab.nModuleArg;
      string zErr = null;
      string zModuleName = sqlite3MPrintf( db, "%s", pTab.zName );

      //if ( String.IsNullOrEmpty( zModuleName ) )
      //{
      //  return SQLITE_NOMEM;
      //}

      pVTable = new VTable();//sqlite3DbMallocZero( db, sizeof( VTable ) );
      //if ( null == pVTable )
      //{
      //  sqlite3DbFree( db, ref zModuleName );
      //  return SQLITE_NOMEM;
      //}
      pVTable.db = db;
      pVTable.pMod = pMod;

      /* Invoke the virtual table constructor */
      //assert( &db->pVtabCtx );
      Debug.Assert( xConstruct != null );
      sCtx.pTab = pTab;
      sCtx.pVTable = pVTable;
      db.pVtabCtx = sCtx;
      rc = xConstruct( db, pMod.pAux, nArg, azArg, out pVTable.pVtab, out zErr );
      db.pVtabCtx = null;
      //if ( rc == SQLITE_NOMEM )
      //  db.mallocFailed = 1;

      if ( SQLITE_OK != rc )
      {
        if ( zErr == "" )
        {
          pzErr = sqlite3MPrintf( db, "vtable constructor failed: %s", zModuleName );
        }
        else
        {
          pzErr = sqlite3MPrintf( db, "%s", zErr );
          zErr = null;//sqlite3_free( zErr );
        }
        sqlite3DbFree( db, ref pVTable );
      }
      else if ( ALWAYS( pVTable.pVtab ) )
      {
        /* Justification of ALWAYS():  A correct vtab constructor must allocate
        ** the sqlite3_vtab object if successful.  */
        pVTable.pVtab.pModule = pMod.pModule;
        pVTable.nRef = 1;
        if ( sCtx.pTab != null )
        {
          string zFormat = "vtable constructor did not declare schema: %s";
          pzErr = sqlite3MPrintf( db, zFormat, pTab.zName );
          sqlite3VtabUnlock( pVTable );
          rc = SQLITE_ERROR;
        }
        else
        {
          int iCol;
          /* If everything went according to plan, link the new VTable structure
          ** into the linked list headed by pTab->pVTable. Then loop through the
          ** columns of the table to see if any of them contain the token "hidden".
          ** If so, set the Column.isHidden flag and remove the token from
          ** the type string.  */
          pVTable.pNext = pTab.pVTable;
          pTab.pVTable = pVTable;

          for ( iCol = 0; iCol < pTab.nCol; iCol++ )
          {
            if ( String.IsNullOrEmpty( pTab.aCol[iCol].zType ) )
              continue;
            StringBuilder zType = new StringBuilder( pTab.aCol[iCol].zType);
            int nType;
            int i = 0;
            //if ( zType )
            //  continue;
            nType = sqlite3Strlen30( zType );
            if ( sqlite3StrNICmp( "hidden", 0, zType.ToString(), 6 ) != 0 || ( zType.Length > 6 && zType[6] != ' ' ) )
            {
              for ( i = 0; i < nType; i++ )
              {
                if ( ( 0 == sqlite3StrNICmp( " hidden", zType.ToString().Substring( i ), 7 ) )
                 && ( i+7 == zType.Length || (zType[i + 7] == '\0' || zType[i + 7] == ' ' ))
                )
                {
                  i++;
                  break;
                }
              }
            }
            if ( i < nType )
            {
              int j;
              int nDel = 6 + ( zType.Length > i + 6 ? 1 : 0 );
              for ( j = i; ( j + nDel ) < nType; j++ )
              {
                zType[j] = zType[j + nDel];
              }
              if ( zType[i] == '\0' && i > 0 )
              {
                Debug.Assert( zType[i - 1] == ' ' );
                zType.Length = i;//[i - 1] = '\0';
              }
              pTab.aCol[iCol].isHidden = 1;
              pTab.aCol[iCol].zType = zType.ToString().Substring(0,j);
            }
          }
        }
      }

      sqlite3DbFree( db, ref zModuleName );
      return rc;
    }