Ejemplo n.º 1
0
        /*
        ** Usage:   btree_ismemdb ID
        **
        ** Return true if the B-Tree is in-memory.
        */
        static int btree_ismemdb(
            object NotUsed,
            Tcl_Interp interp, /* The TCL interpreter that invoked this command */
            int argc,          /* Number of arguments */
            TclObject[] argv   /* Text of each argument */
            )
        {
            Btree pBt;
            int   res;

            if (argc != 2)
            {
                TCL.Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
                                     " ID\"");
                return(TCL.TCL_ERROR);
            }
            pBt = (Btree)sqlite3TestTextToPtr(interp, argv[1].ToString());
            sqlite3_mutex_enter(pBt.db.mutex);
            sqlite3BtreeEnter(pBt);
            res = sqlite3PagerIsMemdb(sqlite3BtreePager(pBt)) ? 1 : 0;
            sqlite3BtreeLeave(pBt);
            sqlite3_mutex_leave(pBt.db.mutex);
            TCL.Tcl_SetObjResult(interp, TCL.Tcl_NewBooleanObj(res));
            return(TCL.TCL_OK);
        }