Example #1
0
        /*
        ** Invoke this routine to create a specific instance of an intarray object.
        ** The new intarray object is returned by the 3rd parameter.
        **
        ** Each intarray object corresponds to a virtual table in the TEMP table
        ** with a name of zName.
        **
        ** Destroy the intarray object by dropping the virtual table.  If not done
        ** explicitly by the application, the virtual table will be dropped implicitly
        ** by the system when the database connection is closed.
        */
        static int sqlite3_intarray_create(
            sqlite3 db,
            string zName,
            out sqlite3_intarray ppReturn
            )
        {
            int rc = SQLITE_OK;

#if !SQLITE_OMIT_VIRTUALTABLE
            sqlite3_intarray p;

            ppReturn = p = new sqlite3_intarray();//sqlite3_malloc( sizeof(*p) );
            //if( p==0 ){
            //  return SQLITE_NOMEM;
            //}
            //memset(p, 0, sizeof(*p));
            rc = sqlite3_create_module_v2(db, zName, intarrayModule, p,
                                          intarrayFree);
            if (rc == SQLITE_OK)
            {
                string zSql;
                zSql = sqlite3_mprintf("CREATE VIRTUAL TABLE temp.%Q USING %Q",
                                       zName, zName);
                rc = sqlite3_exec(db, zSql, 0, 0, 0);
                //sqlite3_free(zSql);
            }
#endif
            return(rc);
        }
Example #2
0
 /*
 ** Bind a new array array of integers to a specific intarray object.
 **
 ** The array of integers bound must be unchanged for the duration of
 ** any query against the corresponding virtual table.  If the integer
 ** array does change or is deallocated undefined behavior will result.
 */
 static int sqlite3_intarray_bind(
     sqlite3_intarray pIntArray, /* The intarray object to bind to */
     int nElements,              /* Number of elements in the intarray */
     sqlite3_int64[] aElements,  /* Content of the intarray */
     dxFree xFree                //void (*xFree)(void*)           /* How to dispose of the intarray when done */
     )
 {
     if (pIntArray.xFree != null)
     {
         pIntArray.a = null;//pIntArray.xFree( pIntArray.a );
     }
     pIntArray.n     = nElements;
     pIntArray.a     = aElements;
     pIntArray.xFree = xFree;
     return(SQLITE_OK);
 }
Example #3
0
 /*
 ** Bind a new array array of integers to a specific intarray object.
 **
 ** The array of integers bound must be unchanged for the duration of
 ** any query against the corresponding virtual table.  If the integer
 ** array does change or is deallocated undefined behavior will result.
 */
 static int sqlite3_intarray_bind(
   sqlite3_intarray pIntArray,    /* The intarray object to bind to */
   int nElements,                 /* Number of elements in the intarray */
   sqlite3_int64[] aElements,     /* Content of the intarray */
   dxFree xFree//void (*xFree)(void*)           /* How to dispose of the intarray when done */
 )
 {
   if ( pIntArray.xFree != null )
   {
     pIntArray.a = null;//pIntArray.xFree( pIntArray.a );
   }
   pIntArray.n = nElements;
   pIntArray.a = aElements;
   pIntArray.xFree = xFree;
   return SQLITE_OK;
 }
Example #4
0
    /*
** Invoke this routine to create a specific instance of an intarray object.
** The new intarray object is returned by the 3rd parameter.
**
** Each intarray object corresponds to a virtual table in the TEMP table
** with a name of zName.
**
** Destroy the intarray object by dropping the virtual table.  If not done
** explicitly by the application, the virtual table will be dropped implicitly
** by the system when the database connection is closed.
*/
    static int sqlite3_intarray_create(
      sqlite3 db,
      string zName,
      out sqlite3_intarray ppReturn
    )
    {
      int rc = SQLITE_OK;
#if !SQLITE_OMIT_VIRTUALTABLE
      sqlite3_intarray p;

      ppReturn = p = new sqlite3_intarray();//sqlite3_malloc( sizeof(*p) );
      //if( p==0 ){
      //  return SQLITE_NOMEM;
      //}
      //memset(p, 0, sizeof(*p));
      rc = sqlite3_create_module_v2( db, zName, intarrayModule, p,
                                    intarrayFree );
      if ( rc == SQLITE_OK )
      {
        string zSql;
        zSql = sqlite3_mprintf( "CREATE VIRTUAL TABLE temp.%Q USING %Q",
                               zName, zName );
        rc = sqlite3_exec( db, zSql, 0, 0, 0 );
        //sqlite3_free(zSql);
      }
#endif
      return rc;
    }