コード例 #1
0
        /*
        ** Retrieve the current rowid.
        */
        static int intarrayRowid(sqlite3_vtab_cursor cur, out sqlite_int64 pRowid)
        {
            intarray_cursor pCur = (intarray_cursor)cur;

            pRowid = pCur.i;
            return(SQLITE_OK);
        }
コード例 #2
0
        /*
        ** Advance the cursor to the next row.
        */
        static int intarrayNext(sqlite3_vtab_cursor cur)
        {
            intarray_cursor pCur = (intarray_cursor)cur;

            pCur.i++;
            return(SQLITE_OK);
        }
コード例 #3
0
        static int intarrayEof(sqlite3_vtab_cursor cur)
        {
            intarray_cursor pCur  = (intarray_cursor)cur;
            intarray_vtab   pVtab = (intarray_vtab)cur.pVtab;

            return(pCur.i >= pVtab.pContent.n ? 1 : 0);
        }
コード例 #4
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
        /*
        ** Called to "rewind" a cursor back to the beginning so that
        ** it starts its output over again.  Always called at least once
        ** prior to any wholenumberColumn, wholenumberRowid, or wholenumberEof call.
        **
        **    idxNum   Constraints
        **    ------   ---------------------
        **      0      (none)
        **      1      value > $argv0
        **      2      value >= $argv0
        **      4      value < $argv0
        **      8      value <= $argv0
        **
        **      5      value > $argv0 AND value < $argv1
        **      6      value >= $argv0 AND value < $argv1
        **      9      value > $argv0 AND value <= $argv1
        **     10      value >= $argv0 AND value <= $argv1
        */
        static int wholenumberFilter(
            sqlite3_vtab_cursor pVtabCursor,
            int idxNum, string idxStr,
            int argc, sqlite3_value[] argv
            )
        {
            wholenumber_cursor pCur = (wholenumber_cursor)pVtabCursor;
            sqlite3_int64      v;
            int i = 0;

            pCur.iValue  = 1;
            pCur.mxValue = 0xffffffff; /* 4294967295 */
            if ((idxNum & 3) != 0)
            {
                v = sqlite3_value_int64(argv[0]) + (idxNum & 1);
                if (v > pCur.iValue && v <= pCur.mxValue)
                {
                    pCur.iValue = (uint)v;
                }
                i++;
            }
            if ((idxNum & 12) != 0)
            {
                v = sqlite3_value_int64(argv[i]) - ((idxNum >> 2) & 1);
                if (v >= pCur.iValue && v < pCur.mxValue)
                {
                    pCur.mxValue = (uint)v;
                }
            }
            return(SQLITE_OK);
        }
コード例 #5
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
        /*
        ** The rowid.
        */
        static int wholenumberRowid(sqlite3_vtab_cursor cur, out sqlite_int64 pRowid)
        {
            wholenumber_cursor pCur = (wholenumber_cursor)cur;

            pRowid = pCur.iValue;
            return(SQLITE_OK);
        }
コード例 #6
0
        /*
        ** Retrieve the current rowid.
        */
        static int schemaRowid(sqlite3_vtab_cursor cur, out sqlite_int64 pRowid)
        {
            schema_cursor pCur = (schema_cursor)cur;

            pRowid = pCur.rowid;
            return(SQLITE_OK);
        }
コード例 #7
0
 /*
 ** Close a intarray table cursor.
 */
 static int intarrayClose(ref sqlite3_vtab_cursor cur)
 {
     //intarray_cursor *pCur = (intarray_cursor *)cur;
     //sqlite3_free(pCur);
     cur = null;
     return(SQLITE_OK);
 }
コード例 #8
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
        /*
        ** Advance a cursor to its next row of output
        */
        static int wholenumberNext(sqlite3_vtab_cursor cur)
        {
            wholenumber_cursor pCur = (wholenumber_cursor)cur;

            pCur.iValue++;
            return(SQLITE_OK);
        }
コード例 #9
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
/* The xDisconnect and xDestroy methods are also the same */

/*
** Open a new tclvar cursor.
*/
        static int tclvarOpen(sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor)
        {
            //tclvar_cursor pCur;
            //pCur = sqlite3MallocZero(sizeof(tclvar_cursor));
            //*ppCursor = pCur.base;
            ppCursor = new tclvar_cursor();
            return(SQLITE_OK);
        }
コード例 #10
0
ファイル: test_fuzzer_c.cs プロジェクト: ekicyou/pasta
        /*
        ** Close a fuzzer cursor.
        */
        static int fuzzerClose(ref sqlite3_vtab_cursor cur)
        {
            fuzzer_cursor pCur = (fuzzer_cursor)cur;

            fuzzerClearCursor(pCur, 0);
            //sqlite3_free(pCur.zBuf);
            pCur.pVtab.nCursor--;
            cur = null;//sqlite3_free( pCur );
            return(SQLITE_OK);
        }
コード例 #11
0
        /*
        ** Retrieve a column of data.
        */
        static int intarrayColumn(sqlite3_vtab_cursor cur, sqlite3_context ctx, int i)
        {
            intarray_cursor pCur  = (intarray_cursor)cur;
            intarray_vtab   pVtab = (intarray_vtab)cur.pVtab;

            if (pCur.i >= 0 && pCur.i < pVtab.pContent.n)
            {
                sqlite3_result_int64(ctx, pVtab.pContent.a[pCur.i]);
            }
            return(SQLITE_OK);
        }
コード例 #12
0
        /*
        ** Close a schema table cursor.
        */
        static int schemaClose(ref sqlite3_vtab_cursor cur)
        {
            schema_cursor pCur = (schema_cursor)cur;

            sqlite3_finalize(pCur.pDbList);
            sqlite3_finalize(pCur.pTableList);
            sqlite3_finalize(pCur.pColumnList);
            //sqlite3_free( pCur );
            cur = null;//
            return(SQLITE_OK);
        }
コード例 #13
0
        /*
        ** Reset a intarray table cursor.
        */
        static int intarrayFilter(
            sqlite3_vtab_cursor pVtabCursor,
            int idxNum, string idxStr,
            int argc, sqlite3_value[] argv
            )
        {
            intarray_cursor pCur = (intarray_cursor)pVtabCursor;

            pCur.i = 0;
            return(SQLITE_OK);
        }
コード例 #14
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
        /* The xDisconnect and xDestroy methods are also the same */


        /*
        ** Open a new wholenumber cursor.
        */
        static int wholenumberOpen(sqlite3_vtab p, out sqlite3_vtab_cursor ppCursor)
        {
            wholenumber_cursor pCur;

            pCur = new wholenumber_cursor();//sqlite3_malloc( sizeof(*pCur) );
            //if ( pCur == null )
            //  return SQLITE_NOMEM;
            //memset(pCur, 0, sizeof(*pCur));
            ppCursor = pCur;//.base;
            return(SQLITE_OK);
        }
コード例 #15
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
        /*
        ** Return the value associated with a wholenumber.
        */
        static int wholenumberColumn(
            sqlite3_vtab_cursor cur,
            sqlite3_context ctx,
            int i
            )
        {
            wholenumber_cursor pCur = (wholenumber_cursor)cur;

            sqlite3_result_int64(ctx, pCur.iValue);
            return(SQLITE_OK);
        }
コード例 #16
0
        /*
        ** Open a new cursor on the schema table.
        */
        static int schemaOpen(sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor)
        {
            int           rc = SQLITE_NOMEM;
            schema_cursor pCur;

            pCur = new schema_cursor();//pCur = sqlite3_malloc(sizeof(schema_cursor));
            //if ( pCur != null )
            //{
            //memset(pCur, 0, sizeof(schema_cursor));
            ppCursor = (sqlite3_vtab_cursor)pCur;
            rc       = SQLITE_OK;
            //}
            return(rc);
        }
コード例 #17
0
        /*
        ** Open a new cursor on the intarray table.
        */
        static int intarrayOpen(sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor)
        {
            int             rc   = SQLITE_NOMEM;
            intarray_cursor pCur = new intarray_cursor();//

            //pCur = sqlite3_malloc(sizeof(intarray_cursor));
            //if ( pCur != null )
            {
                //memset(pCur, 0, sizeof(intarray_cursor));
                ppCursor = (sqlite3_vtab_cursor)pCur;
                rc       = SQLITE_OK;
            }
            return(rc);
        }
コード例 #18
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
/*
** Close a tclvar cursor.
*/
        static int tclvarClose(ref sqlite3_vtab_cursor cur)
        {
            tclvar_cursor pCur = (tclvar_cursor )cur;

            if (pCur.pList1 != null)
            {
                TCL.Tcl_DecrRefCount(ref pCur.pList1);
            }
            if (pCur.pList2 != null)
            {
                TCL.Tcl_DecrRefCount(ref pCur.pList2);
            }
            cur = null;//sqlite3_free(pCur);
            return(SQLITE_OK);
        }
コード例 #19
0
        /*
        ** Reset a schema table cursor.
        */
        static int schemaFilter(
            sqlite3_vtab_cursor pVtabCursor,
            int idxNum,
            string idxStr,
            int argc,
            sqlite3_value[] argv
            )
        {
            int           rc;
            schema_vtab   pVtab = (schema_vtab)(pVtabCursor.pVtab);
            schema_cursor pCur  = (schema_cursor)pVtabCursor;

            pCur.rowid = 0;
            finalize(ref pCur.pTableList);
            finalize(ref pCur.pColumnList);
            finalize(ref pCur.pDbList);
            rc = sqlite3_prepare(pVtab.db, "PRAGMA database_list", -1, ref pCur.pDbList, 0);
            return(rc == SQLITE_OK ? schemaNext(pVtabCursor) : rc);
        }
コード例 #20
0
        /*
        ** Retrieve a column of data.
        */
        static int schemaColumn(sqlite3_vtab_cursor cur, sqlite3_context ctx, int i)
        {
            schema_cursor pCur = (schema_cursor)cur;

            switch (i)
            {
            case 0:
                sqlite3_result_value(ctx, sqlite3_column_value(pCur.pDbList, 1));
                break;

            case 1:
                sqlite3_result_value(ctx, sqlite3_column_value(pCur.pTableList, 0));
                break;

            default:
                sqlite3_result_value(ctx, sqlite3_column_value(pCur.pColumnList, i - 2));
                break;
            }
            return(SQLITE_OK);
        }
コード例 #21
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
        static int tclvarNext(sqlite3_vtab_cursor cur)
        {
            Tcl_Obj pObj = null;
            int     n    = 0;
            int     ok   = 0;

            tclvar_cursor pCur   = (tclvar_cursor )cur;
            Tcl_Interp    interp = ((tclvar_vtab )(cur.pVtab)).interp;

            TCL.Tcl_ListObjLength(null, pCur.pList1, out n);
            while (0 == ok && pCur.i1 < n)
            {
                TCL.Tcl_ListObjIndex(null, pCur.pList1, pCur.i1, out pObj);
                ok = next2(interp, pCur, pObj);
                if (0 == ok)
                {
                    pCur.i1++;
                }
            }

            return(0);
        }
コード例 #22
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
        static int tclvarFilter(
            sqlite3_vtab_cursor pVtabCursor,
            int idxNum, string idxStr,
            int argc, sqlite3_value[] argv
            )
        {
            tclvar_cursor pCur   = (tclvar_cursor )pVtabCursor;
            Tcl_Interp    interp = ((tclvar_vtab )(pVtabCursor.pVtab)).interp;

            Tcl_Obj p = TCL.Tcl_NewStringObj("info vars", -1);

            TCL.Tcl_IncrRefCount(p);

            Debug.Assert(argc == 0 || argc == 1);
            if (argc == 1)
            {
                Tcl_Obj pArg = TCL.Tcl_NewStringObj((string)sqlite3_value_text(argv[0]), -1);
                TCL.Tcl_ListObjAppendElement(null, p, pArg);
            }
            TCL.Tcl_EvalObjEx(interp, p, TCL.TCL_EVAL_GLOBAL);
            if (pCur.pList1 != null)
            {
                TCL.Tcl_DecrRefCount(ref pCur.pList1);
            }
            if (pCur.pList2 != null)
            {
                TCL.Tcl_DecrRefCount(ref pCur.pList2);
                pCur.pList2 = null;
            }
            pCur.i1     = 0;
            pCur.i2     = 0;
            pCur.pList1 = TCL.Tcl_GetObjResult(interp);
            TCL.Tcl_IncrRefCount(pCur.pList1);
            Debug.Assert(pCur.i1 == 0 && pCur.i2 == 0 && pCur.pList2 == null);

            TCL.Tcl_DecrRefCount(ref p);
            return(tclvarNext(pVtabCursor));
        }
コード例 #23
0
ファイル: test_fuzzer_c.cs プロジェクト: ekicyou/pasta
        /*
        ** Open a new fuzzer cursor.
        */
        static int fuzzerOpen(sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor)
        {
            fuzzer_vtab   p = (fuzzer_vtab)pVTab;
            fuzzer_cursor pCur;

            pCur = new fuzzer_cursor();//= sqlite3_malloc( sizeof(pCur) );
            ///if( pCur==0 ) return SQLITE_NOMEM;
            //memset(pCur, 0, sizeof(pCur));
            pCur.pVtab = p;
            ppCursor   = pCur;
            if (p.nCursor == 0 && p.pNewRule != null)
            {
                uint          i;
                fuzzer_rule   pX;
                fuzzer_rule[] a = new fuzzer_rule[15];
                //for(i=0; i<sizeof(a)/sizeof(a[0]); i++) a[i] = 0;
                while ((pX = p.pNewRule) != null)
                {
                    p.pNewRule = pX.pNext;
                    pX.pNext   = null;
                    for (i = 0; a[i] != null && i < a.Length; i++)//<sizeof(a)/sizeof(a[0])-1; i++)
                    {
                        pX   = fuzzerMergeRules(a[i], pX);
                        a[i] = null;
                    }
                    a[i] = fuzzerMergeRules(a[i], pX);
                }
                for (pX = a[0], i = 1; i < a.Length; i++)//sizeof(a)/sizeof(a[0]); i++)
                {
                    pX = fuzzerMergeRules(a[i], pX);
                }
                p.pRule = fuzzerMergeRules(p.pRule, pX);
            }
            p.nCursor++;
            return(SQLITE_OK);
        }
コード例 #24
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
        static int tclvarColumn(sqlite3_vtab_cursor cur, sqlite3_context ctx, int i)
        {
            Tcl_Obj       p1 = null;
            Tcl_Obj       p2 = null;
            string        z1;
            string        z2     = "";
            tclvar_cursor pCur   = (tclvar_cursor)cur;
            Tcl_Interp    interp = ((tclvar_vtab )cur.pVtab).interp;

            TCL.Tcl_ListObjIndex(interp, pCur.pList1, pCur.i1, out p1);
            TCL.Tcl_ListObjIndex(interp, pCur.pList2, pCur.i2, out p2);
            z1 = TCL.Tcl_GetString(p1);
            if (p2 != null)
            {
                z2 = TCL.Tcl_GetString(p2);
            }
            switch (i)
            {
            case 0: {
                sqlite3_result_text(ctx, z1, -1, SQLITE_TRANSIENT);
                break;
            }

            case 1: {
                sqlite3_result_text(ctx, z2, -1, SQLITE_TRANSIENT);
                break;
            }

            case 2: {
                Tcl_Obj pVal = TCL.Tcl_GetVar2Ex(interp, z1, z2 == "" ? null : z2, (TCL.VarFlag)TCL.TCL_GLOBAL_ONLY);
                sqlite3_result_text(ctx, TCL.Tcl_GetString(pVal), -1, SQLITE_TRANSIENT);
                break;
            }
            }
            return(SQLITE_OK);
        }
コード例 #25
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
    /* 
    ** Echo virtual table module xRowid method.
    */
    static int echoRowid( sqlite3_vtab_cursor cur, out sqlite_int64 pRowid )
    {
      sqlite3_stmt pStmt = ( (echo_cursor)cur ).pStmt;

      if ( simulateVtabError( (echo_vtab)( cur.pVtab ), "xRowid" ) != 0 )
      {
        pRowid = 0;
        return SQLITE_ERROR;
      }

      pRowid = sqlite3_column_int64( pStmt, 0 );
      return SQLITE_OK;
    }
コード例 #26
0
static int tclvarEof(sqlite3_vtab_cursor cur){
  tclvar_cursor pCur = (tclvar_cursor)cur;
  return ( pCur.pList2 != null ? 0 : 1 );
}
コード例 #27
0
/* The xDisconnect and xDestroy methods are also the same */

/*
** Open a new tclvar cursor.
*/
static int tclvarOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor )
{
  //tclvar_cursor pCur;
  //pCur = sqlite3MallocZero(sizeof(tclvar_cursor));
  //*ppCursor = pCur.base;
  ppCursor = new tclvar_cursor();
  return SQLITE_OK;
}
コード例 #28
0
static int tclvarColumn(sqlite3_vtab_cursor cur, sqlite3_context ctx, int i){
  Tcl_Obj p1=null;
  Tcl_Obj p2=null;
  string z1; 
  string z2 = "";
  tclvar_cursor pCur = (tclvar_cursor)cur;
  Tcl_Interp interp = ((tclvar_vtab )cur.pVtab).interp;

  TCL.Tcl_ListObjIndex( interp, pCur.pList1, pCur.i1, out p1 );
  TCL.Tcl_ListObjIndex( interp, pCur.pList2, pCur.i2, out p2 );
  z1 = TCL.Tcl_GetString(p1);
  if( p2!=null ){
    z2 = TCL.Tcl_GetString(p2);
  }
  switch (i) {
    case 0: {
      sqlite3_result_text(ctx, z1, -1, SQLITE_TRANSIENT);
      break;
    }
    case 1: {
      sqlite3_result_text(ctx, z2, -1, SQLITE_TRANSIENT);
      break;
    }
    case 2: {
      Tcl_Obj pVal = TCL.Tcl_GetVar2Ex( interp, z1, z2 == "" ? null : z2, (TCL.VarFlag)TCL.TCL_GLOBAL_ONLY );
      sqlite3_result_text( ctx, TCL.Tcl_GetString( pVal ), -1, SQLITE_TRANSIENT );
      break;
    }
  }
  return SQLITE_OK;
}
コード例 #29
0
static int tclvarRowid( sqlite3_vtab_cursor cur, out sqlite_int64 pRowid )
{
  pRowid = 0;
  return SQLITE_OK;
}
コード例 #30
0
static int tclvarNext(sqlite3_vtab_cursor cur){
  Tcl_Obj pObj = null;
  int n = 0;
  int ok = 0;

  tclvar_cursor pCur = (tclvar_cursor )cur;
  Tcl_Interp interp = ((tclvar_vtab )(cur.pVtab)).interp;

  TCL.Tcl_ListObjLength( null, pCur.pList1, out n );
  while( 0==ok && pCur.i1<n ){
    TCL.Tcl_ListObjIndex( null, pCur.pList1, pCur.i1, out pObj );
    ok = next2(interp, pCur, pObj);
    if( 0==ok ){
      pCur.i1++;
    }
  }

  return 0;
}
コード例 #31
0
static int tclvarFilter(
  sqlite3_vtab_cursor pVtabCursor, 
  int idxNum, string idxStr,
  int argc, sqlite3_value[] argv
){
  tclvar_cursor pCur = (tclvar_cursor )pVtabCursor;
  Tcl_Interp interp = ((tclvar_vtab )(pVtabCursor.pVtab)).interp;

  Tcl_Obj p = TCL.Tcl_NewStringObj("info vars", -1);
  TCL.Tcl_IncrRefCount(p);

  Debug.Assert( argc==0 || argc==1 );
  if( argc==1 ){
    Tcl_Obj pArg = TCL.Tcl_NewStringObj((string)sqlite3_value_text(argv[0]), -1);
    TCL.Tcl_ListObjAppendElement(null, p, pArg);
  }
  TCL.Tcl_EvalObjEx(interp, p, TCL.TCL_EVAL_GLOBAL);
  if( pCur.pList1 !=null){
    TCL.Tcl_DecrRefCount(ref pCur.pList1);
  }
  if( pCur.pList2 !=null ){
    TCL.Tcl_DecrRefCount(ref pCur.pList2);
    pCur.pList2 = null;
  }
  pCur.i1 = 0;
  pCur.i2 = 0;
  pCur.pList1 = TCL.Tcl_GetObjResult(interp);
  TCL.Tcl_IncrRefCount(pCur.pList1);
  Debug.Assert( pCur.i1==0 && pCur.i2==0 && pCur.pList2==null );

  TCL.Tcl_DecrRefCount(ref p);
  return tclvarNext(pVtabCursor);
}
コード例 #32
0
        /*
        ** Advance the cursor to the next row.
        */
        static int schemaNext(sqlite3_vtab_cursor cur)
        {
            int           rc    = SQLITE_OK;
            schema_cursor pCur  = (schema_cursor)cur;
            schema_vtab   pVtab = (schema_vtab)(cur.pVtab);
            string        zSql  = null;

            while (null == pCur.pColumnList || SQLITE_ROW != sqlite3_step(pCur.pColumnList))
            {
                if (SQLITE_OK != (rc = finalize(ref pCur.pColumnList)))
                {
                    goto next_exit;
                }

                while (null == pCur.pTableList || SQLITE_ROW != sqlite3_step(pCur.pTableList))
                {
                    if (SQLITE_OK != (rc = finalize(ref pCur.pTableList)))
                    {
                        goto next_exit;
                    }

                    Debug.Assert(pCur.pDbList != null);
                    while (SQLITE_ROW != sqlite3_step(pCur.pDbList))
                    {
                        rc = finalize(ref pCur.pDbList);
                        goto next_exit;
                    }

                    /* Set zSql to the SQL to pull the list of tables from the
                    ** sqlite_master (or sqlite_temp_master) table of the database
                    ** identfied by the row pointed to by the SQL statement pCur.pDbList
                    ** (iterating through a "PRAGMA database_list;" statement).
                    */
                    if (sqlite3_column_int(pCur.pDbList, 0) == 1)
                    {
                        zSql = sqlite3_mprintf(
                            "SELECT name FROM sqlite_temp_master WHERE type='table'"
                            );
                    }
                    else
                    {
                        sqlite3_stmt pDbList = pCur.pDbList;
                        zSql = sqlite3_mprintf(
                            "SELECT name FROM %Q.sqlite_master WHERE type='table'",
                            sqlite3_column_text(pDbList, 1)
                            );
                    }
                    //if( !zSql ){
                    //  rc = SQLITE_NOMEM;
                    //  goto next_exit;
                    //}
                    rc = sqlite3_prepare(pVtab.db, zSql, -1, ref pCur.pTableList, 0);
                    //sqlite3_free(zSql);
                    if (rc != SQLITE_OK)
                    {
                        goto next_exit;
                    }
                }

                /* Set zSql to the SQL to the table_info pragma for the table currently
                ** identified by the rows pointed to by statements pCur.pDbList and
                ** pCur.pTableList.
                */
                zSql = sqlite3_mprintf("PRAGMA %Q.table_info(%Q)",
                                       sqlite3_column_text(pCur.pDbList, 1),
                                       sqlite3_column_text(pCur.pTableList, 0)
                                       );

                //if( !Sql ){
                //  rc = SQLITE_NOMEM;
                //  goto next_exit;
                //}
                rc = sqlite3_prepare(pVtab.db, zSql, -1, ref pCur.pColumnList, 0);
                //sqlite3_free(zSql);
                if (rc != SQLITE_OK)
                {
                    goto next_exit;
                }
            }
            pCur.rowid++;

next_exit:
            /* TODO: Handle rc */
            return(rc);
        }
コード例 #33
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
        /*
        ** When the wholenumber_cursor.rLimit value is 0 or less, that is a signal
        ** that the cursor has nothing more to output.
        */
        static int wholenumberEof(sqlite3_vtab_cursor cur)
        {
            wholenumber_cursor pCur = (wholenumber_cursor)cur;

            return((pCur.iValue > pCur.mxValue || pCur.iValue == 0) ? 1 : 0);
        }
コード例 #34
0
 /*
 ** Open a new cursor on the intarray table.
 */
 static int intarrayOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor )
 {
   int rc = SQLITE_NOMEM;
   intarray_cursor pCur = new intarray_cursor();//
   //pCur = sqlite3_malloc(sizeof(intarray_cursor));
   //if ( pCur != null )
   {
     //memset(pCur, 0, sizeof(intarray_cursor));
     ppCursor = (sqlite3_vtab_cursor)pCur;
     rc = SQLITE_OK;
   }
   return rc;
 }
コード例 #35
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
        static int tclvarEof(sqlite3_vtab_cursor cur)
        {
            tclvar_cursor pCur = (tclvar_cursor)cur;

            return(pCur.pList2 != null ? 0 : 1);
        }
コード例 #36
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
    /* 
    ** Echo virtual table module xNext method.
    */
    static int echoNext( sqlite3_vtab_cursor cur )
    {
      int rc = SQLITE_OK;
      echo_cursor pCur = (echo_cursor)cur;

      if ( simulateVtabError( (echo_vtab)( cur.pVtab ), "xNext" ) != 0 )
      {
        return SQLITE_ERROR;
      }

      if ( pCur.pStmt != null )
      {
        rc = sqlite3_step( pCur.pStmt );
        if ( rc == SQLITE_ROW )
        {
          rc = SQLITE_OK;
        }
        else
        {
          rc = sqlite3_finalize( pCur.pStmt );
          pCur.pStmt = null;
        }
      }

      return rc;
    }
コード例 #37
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
 /* 
 ** Echo virtual table module xClose method.
 */
 static int echoClose( ref sqlite3_vtab_cursor cur )
 {
   int rc = 0;
   echo_cursor pCur = (echo_cursor)cur;
   sqlite3_stmt pStmt = pCur.pStmt;
   pCur.pStmt = null;
   //sqlite3_free(pCur);
   pCur = null;
   rc = sqlite3_finalize( pStmt );
   return rc;
 }
コード例 #38
0
 /*
 ** Reset a intarray table cursor.
 */
 static int intarrayFilter(
   sqlite3_vtab_cursor pVtabCursor,
   int idxNum, string idxStr,
   int argc, sqlite3_value[] argv
 )
 {
   intarray_cursor pCur = (intarray_cursor)pVtabCursor;
   pCur.i = 0;
   return SQLITE_OK;
 }
コード例 #39
0
 static int intarrayEof( sqlite3_vtab_cursor cur )
 {
   intarray_cursor pCur = (intarray_cursor)cur;
   intarray_vtab pVtab = (intarray_vtab)cur.pVtab;
   return pCur.i >= pVtab.pContent.n ? 1 : 0;
 }
コード例 #40
0
 /*
 ** Retrieve a column of data.
 */
 static int intarrayColumn( sqlite3_vtab_cursor cur, sqlite3_context ctx, int i )
 {
   intarray_cursor pCur = (intarray_cursor)cur;
   intarray_vtab pVtab = (intarray_vtab)cur.pVtab;
   if ( pCur.i >= 0 && pCur.i < pVtab.pContent.n )
   {
     sqlite3_result_int64( ctx, pVtab.pContent.a[pCur.i] );
   }
   return SQLITE_OK;
 }
コード例 #41
0
ファイル: test_tclvar_c.cs プロジェクト: ekicyou/pasta
 static int tclvarRowid(sqlite3_vtab_cursor cur, out sqlite_int64 pRowid)
 {
     pRowid = 0;
     return(SQLITE_OK);
 }
コード例 #42
0
 /*
 ** Close a fuzzer cursor.
 */
 static int fuzzerClose( ref sqlite3_vtab_cursor cur )
 {
   fuzzer_cursor pCur = (fuzzer_cursor)cur;
   fuzzerClearCursor( pCur, 0 );
   //sqlite3_free(pCur.zBuf);
   pCur.pVtab.nCursor--;
   cur = null;//sqlite3_free( pCur );
   return SQLITE_OK;
 }
コード例 #43
0
        static int schemaEof(sqlite3_vtab_cursor cur)
        {
            schema_cursor pCur = (schema_cursor)cur;

            return(pCur.pDbList != null ? 0 : 1);
        }
コード例 #44
0
/*
** Close a tclvar cursor.
*/
static int tclvarClose( ref sqlite3_vtab_cursor cur )
{
  tclvar_cursor pCur = (tclvar_cursor )cur;
  if( pCur.pList1 != null){
    TCL.Tcl_DecrRefCount(ref pCur.pList1);
  }
  if( pCur.pList2 != null){
    TCL.Tcl_DecrRefCount( ref pCur.pList2 );
  }
  cur = null;//sqlite3_free(pCur);
  return SQLITE_OK;
}
コード例 #45
0
 /*
 ** Open a new cursor on the schema table.
 */
 static int schemaOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor )
 {
   int rc = SQLITE_NOMEM;
   schema_cursor pCur;
   pCur = new schema_cursor();//pCur = sqlite3_malloc(sizeof(schema_cursor));
   //if ( pCur != null )
   //{
     //memset(pCur, 0, sizeof(schema_cursor));
     ppCursor = (sqlite3_vtab_cursor)pCur;
     rc = SQLITE_OK;
   //}
   return rc;
 }
コード例 #46
0
ファイル: test_wholenumber_c.cs プロジェクト: ekicyou/pasta
 /*
 ** Close a wholenumber cursor.
 */
 static int wholenumberClose(ref sqlite3_vtab_cursor cur)
 {
     cur = null;//  sqlite3_free( ref cur );
     return(SQLITE_OK);
 }
コード例 #47
0
 /*
 ** Close a intarray table cursor.
 */
 static int intarrayClose( ref sqlite3_vtab_cursor cur )
 {
   //intarray_cursor *pCur = (intarray_cursor *)cur;
   //sqlite3_free(pCur);
   cur = null;
   return SQLITE_OK;
 }
コード例 #48
0
 /*
 ** Close a schema table cursor.
 */
 static int schemaClose( ref sqlite3_vtab_cursor cur )
 {
   schema_cursor pCur = (schema_cursor)cur;
   sqlite3_finalize( pCur.pDbList );
   sqlite3_finalize( pCur.pTableList );
   sqlite3_finalize( pCur.pColumnList );
   //sqlite3_free( pCur );
   cur = null;//
   return SQLITE_OK;
 }
コード例 #49
0
 /*
 ** Retrieve the current rowid.
 */
 static int intarrayRowid( sqlite3_vtab_cursor cur, out sqlite_int64 pRowid )
 {
   intarray_cursor pCur = (intarray_cursor)cur;
   pRowid = pCur.i;
   return SQLITE_OK;
 }
コード例 #50
0
 /*
 ** Retrieve a column of data.
 */
 static int schemaColumn( sqlite3_vtab_cursor cur, sqlite3_context ctx, int i )
 {
   schema_cursor pCur = (schema_cursor)cur;
   switch ( i )
   {
     case 0:
       sqlite3_result_value( ctx, sqlite3_column_value( pCur.pDbList, 1 ) );
       break;
     case 1:
       sqlite3_result_value( ctx, sqlite3_column_value( pCur.pTableList, 0 ) );
       break;
     default:
       sqlite3_result_value( ctx, sqlite3_column_value( pCur.pColumnList, i - 2 ) );
       break;
   }
   return SQLITE_OK;
 }
コード例 #51
0
 /*
 ** Advance the cursor to the next row.
 */
 static int intarrayNext( sqlite3_vtab_cursor cur )
 {
   intarray_cursor pCur = (intarray_cursor)cur;
   pCur.i++;
   return SQLITE_OK;
 }
コード例 #52
0
 /*
 ** Retrieve the current rowid.
 */
 static int schemaRowid( sqlite3_vtab_cursor cur, out sqlite_int64 pRowid )
 {
   schema_cursor pCur = (schema_cursor)cur;
   pRowid = pCur.rowid;
   return SQLITE_OK;
 }
コード例 #53
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
 /* 
 ** Echo virtual table module xOpen method.
 */
 static int echoOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor )
 {
   echo_cursor pCur;
   if ( simulateVtabError( (echo_vtab)pVTab, "xOpen" ) != 0 )
   {
     ppCursor = null;
     return SQLITE_ERROR;
   }
   pCur = new echo_cursor();//sqlite3MallocZero( sizeof( echo_cursor ) );
   ppCursor = (sqlite3_vtab_cursor)pCur;
   return ( pCur != null ? SQLITE_OK : SQLITE_NOMEM );
 }
コード例 #54
0
 static int schemaEof( sqlite3_vtab_cursor cur )
 {
   schema_cursor pCur = (schema_cursor)cur;
   return ( pCur.pDbList != null ? 0 : 1 );
 }
コード例 #55
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
 /*
 ** Return non-zero if the cursor does not currently point to a valid record
 ** (i.e if the scan has finished), or zero otherwise.
 */
 static int echoEof( sqlite3_vtab_cursor cur )
 {
   return ( ( (echo_cursor)cur ).pStmt != null ? 0 : 1 );
 }
コード例 #56
0
    /*
    ** Advance the cursor to the next row.
    */
    static int schemaNext( sqlite3_vtab_cursor cur )
    {
      int rc = SQLITE_OK;
      schema_cursor pCur = (schema_cursor)cur;
      schema_vtab pVtab = (schema_vtab)( cur.pVtab );
      string zSql = null;

      while ( null == pCur.pColumnList || SQLITE_ROW != sqlite3_step( pCur.pColumnList ) )
      {
        if ( SQLITE_OK != ( rc = finalize( ref pCur.pColumnList ) ) )
          goto next_exit;

        while ( null == pCur.pTableList || SQLITE_ROW != sqlite3_step( pCur.pTableList ) )
        {
          if ( SQLITE_OK != ( rc = finalize( ref pCur.pTableList ) ) )
            goto next_exit;

          Debug.Assert( pCur.pDbList !=null);
          while ( SQLITE_ROW != sqlite3_step( pCur.pDbList ) )
          {
            rc = finalize( ref pCur.pDbList );
            goto next_exit;
          }

          /* Set zSql to the SQL to pull the list of tables from the 
          ** sqlite_master (or sqlite_temp_master) table of the database
          ** identfied by the row pointed to by the SQL statement pCur.pDbList
          ** (iterating through a "PRAGMA database_list;" statement).
          */
          if ( sqlite3_column_int( pCur.pDbList, 0 ) == 1 )
          {
            zSql = sqlite3_mprintf(
                "SELECT name FROM sqlite_temp_master WHERE type='table'"
            );
          }
          else
          {
            sqlite3_stmt pDbList = pCur.pDbList;
            zSql = sqlite3_mprintf(
                "SELECT name FROM %Q.sqlite_master WHERE type='table'",
                 sqlite3_column_text( pDbList, 1 )
            );
          }
          //if( !zSql ){
          //  rc = SQLITE_NOMEM;
          //  goto next_exit;
          //}
          rc = sqlite3_prepare( pVtab.db, zSql, -1, ref pCur.pTableList, 0 );
          //sqlite3_free(zSql);
          if ( rc != SQLITE_OK )
            goto next_exit;
        }

        /* Set zSql to the SQL to the table_info pragma for the table currently
        ** identified by the rows pointed to by statements pCur.pDbList and
        ** pCur.pTableList.
        */
        zSql = sqlite3_mprintf( "PRAGMA %Q.table_info(%Q)",
            sqlite3_column_text( pCur.pDbList, 1 ),
            sqlite3_column_text( pCur.pTableList, 0 )
        );

        //if( !Sql ){
        //  rc = SQLITE_NOMEM;
        //  goto next_exit;
        //}
        rc = sqlite3_prepare( pVtab.db, zSql, -1, ref pCur.pColumnList, 0 );
        //sqlite3_free(zSql);
        if ( rc != SQLITE_OK )
          goto next_exit;
      }
      pCur.rowid++;

next_exit:
      /* TODO: Handle rc */
      return rc;
    }
コード例 #57
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
    /* 
    ** Echo virtual table module xColumn method.
    */
    static int echoColumn( sqlite3_vtab_cursor cur, sqlite3_context ctx, int i )
    {
      int iCol = i + 1;
      sqlite3_stmt pStmt = ( (echo_cursor)cur ).pStmt;

      if ( simulateVtabError( (echo_vtab)( cur.pVtab ), "xColumn" ) != 0 )
      {
        return SQLITE_ERROR;
      }

      if ( null == pStmt )
      {
        sqlite3_result_null( ctx );
      }
      else
      {
        Debug.Assert( sqlite3_data_count( pStmt ) > iCol );
        sqlite3_result_value( ctx, sqlite3_column_value( pStmt, iCol ) );
      }
      return SQLITE_OK;
    }
コード例 #58
0
 /*
 ** Reset a schema table cursor.
 */
 static int schemaFilter(
   sqlite3_vtab_cursor pVtabCursor,
   int idxNum,
   string idxStr,
   int argc,
   sqlite3_value[] argv
 )
 {
   int rc;
   schema_vtab pVtab = (schema_vtab)( pVtabCursor.pVtab );
   schema_cursor pCur = (schema_cursor)pVtabCursor;
   pCur.rowid = 0;
   finalize( ref pCur.pTableList );
   finalize( ref pCur.pColumnList );
   finalize( ref pCur.pDbList );
   rc = sqlite3_prepare( pVtab.db, "PRAGMA database_list", -1, ref pCur.pDbList, 0 );
   return ( rc == SQLITE_OK ? schemaNext( pVtabCursor ) : rc );
 }
コード例 #59
0
ファイル: test8_c.cs プロジェクト: Jaden-J/csharp-sqlite
    /* 
    ** Echo virtual table module xFilter method.
    */
    static int echoFilter(
      sqlite3_vtab_cursor pVtabCursor,
      int idxNum, string idxStr,
      int argc, sqlite3_value[] argv
    )
    {
      int rc;
      int i;

      echo_cursor pCur = (echo_cursor)pVtabCursor;
      echo_vtab pVtab = (echo_vtab)pVtabCursor.pVtab;
      sqlite3 db = pVtab.db;

      if ( simulateVtabError( pVtab, "xFilter" ) != 0 )
      {
        return SQLITE_ERROR;
      }

      /* Check that idxNum matches idxStr */
      Debug.Assert( idxNum == hashString( idxStr ) );

      /* Log arguments to the ::echo_module Tcl variable */
      appendToEchoModule( pVtab.interp, "xFilter" );
      appendToEchoModule( pVtab.interp, idxStr );
      for ( i = 0; i < argc; i++ )
      {
        appendToEchoModule( pVtab.interp, sqlite3_value_text( argv[i] ) );
      }

      sqlite3_finalize( pCur.pStmt );
      pCur.pStmt = null;

      /* Prepare the SQL statement created by echoBestIndex and bind the
      ** runtime parameters passed to this function to it.
      */
      rc = sqlite3_prepare( db, idxStr, -1, ref pCur.pStmt, 0 );
      Debug.Assert( pCur.pStmt != null || rc != SQLITE_OK );
      for ( i = 0; rc == SQLITE_OK && i < argc; i++ )
      {
        rc = sqlite3_bind_value( pCur.pStmt, i + 1, argv[i] );
      }

      /* If everything was successful, advance to the first row of the scan */
      if ( rc == SQLITE_OK )
      {
        rc = echoNext( pVtabCursor );
      }

      return rc;
    }
コード例 #60
0
 /*
 ** Open a new fuzzer cursor.
 */
 static int fuzzerOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor )
 {
   fuzzer_vtab p = (fuzzer_vtab)pVTab;
   fuzzer_cursor pCur;
   pCur = new fuzzer_cursor();//= sqlite3_malloc( sizeof(pCur) );
   ///if( pCur==0 ) return SQLITE_NOMEM;
   //memset(pCur, 0, sizeof(pCur));
   pCur.pVtab = p;
   ppCursor = pCur;
   if ( p.nCursor == 0 && p.pNewRule != null )
   {
     uint i;
     fuzzer_rule pX;
     fuzzer_rule[] a = new fuzzer_rule[15];
     //for(i=0; i<sizeof(a)/sizeof(a[0]); i++) a[i] = 0;
     while ( ( pX = p.pNewRule ) != null )
     {
       p.pNewRule = pX.pNext;
       pX.pNext = null;
       for ( i = 0; a[i] != null && i < a.Length; i++ )//<sizeof(a)/sizeof(a[0])-1; i++)
       {
         pX = fuzzerMergeRules( a[i], pX );
         a[i] = null;
       }
       a[i] = fuzzerMergeRules( a[i], pX );
     }
     for ( pX = a[0], i = 1; i < a.Length; i++ )//sizeof(a)/sizeof(a[0]); i++)
     {
       pX = fuzzerMergeRules( a[i], pX );
     }
     p.pRule = fuzzerMergeRules( p.pRule, pX );
   }
   p.nCursor++;
   return SQLITE_OK;
 }