Ejemplo n.º 1
0
 // was:sqlite3BtreeCursor
 public RC Cursor(int iTable, bool wrFlag, KeyInfo pKeyInfo, BtreeCursor pCur)
 {
     sqlite3BtreeEnter();
     var rc = btreeCursor(iTable, wrFlag, pKeyInfo, pCur);
     sqlite3BtreeLeave();
     return rc;
 }
Ejemplo n.º 2
0
 internal RC saveAllCursors(Pgno iRoot, BtreeCursor pExcept)
 {
     Debug.Assert(MutexEx.Held(this.Mutex));
     Debug.Assert(pExcept == null || pExcept.Shared == this);
     for (var p = this.Cursors; p != null; p = p.Next)
     {
         if (p != pExcept && (0 == iRoot || p.RootID == iRoot) && p.State == CURSOR.VALID)
         {
             var rc = p.SavePosition();
             if (rc != RC.OK)
             {
                 return(rc);
             }
         }
     }
     return(RC.OK);
 }
Ejemplo n.º 3
0
        public uint[] OverflowIDs; // Cache of overflow page locations

        #endif

        #region Methods

        // was:sqlite3BtreeCursorZero
        public void Zero()
        {
            Next = null;
            Prev = null;
            KeyInfo = null;
            RootID = 0;
            _cachedRowID = 0;
            Info = new MemPage.CellInfo();
            Writeable = false;
            AtLast = false;
            ValidNKey = false;
            State = 0;
            Key = null;
            NKey = 0;
            SkipNext = 0;
            #if !SQLITE_OMIT_INCRBLOB
            IsIncrblob = false;
            OverflowIDs = null;
            #endif
            PageID = 0;
        }
Ejemplo n.º 4
0
        public MemPage[] Pages = new MemPage[BTCURSOR_MAX_DEPTH];     // Pages from root to current page

        // was:sqlite3BtreeCursorZero
        public void Zero()
        {
            Next         = null;
            Prev         = null;
            KeyInfo      = null;
            RootID       = 0;
            _cachedRowID = 0;
            Info         = new MemPage.CellInfo();
            Writeable    = false;
            AtLast       = false;
            ValidNKey    = false;
            State        = 0;
            Key          = null;
            NKey         = 0;
            SkipNext     = 0;
#if !SQLITE_OMIT_INCRBLOB
            IsIncrblob  = false;
            OverflowIDs = null;
#endif
            PageID = 0;
        }
Ejemplo n.º 5
0
        internal RC btreeCursor(int iTable, bool wrFlag, KeyInfo pKeyInfo, BtreeCursor pCur)
        {
            Debug.Assert(sqlite3BtreeHoldsMutex());
            // The following Debug.Assert statements verify that if this is a sharable b-tree database, the connection is holding the required table locks,
            // and that no other connection has any open cursor that conflicts with this lock.
            Debug.Assert(hasSharedCacheTableLock((uint)iTable, (pKeyInfo != null), (wrFlag ? LOCK.READ : LOCK.WRITE)));
            Debug.Assert(!wrFlag || !hasReadConflicts((uint)iTable));
            // Assert that the caller has opened the required transaction.
            Debug.Assert(this.InTransaction > TRANS.NONE);
            Debug.Assert(!wrFlag || this.InTransaction == TRANS.WRITE);
            var pBt = this.Shared;                 // Shared b-tree handle

            Debug.Assert(pBt.Page1 != null && pBt.Page1.Data != null);
            if (Check.NEVER(wrFlag && pBt.ReadOnly))
            {
                return(RC.READONLY);
            }
            if (iTable == 1 && pBt.btreePagecount() == 0)
            {
                return(RC.EMPTY);
            }
            // Now that no other errors can occur, finish filling in the BtCursor variables and link the cursor into the BtShared list.
            pCur.RootID    = (Pgno)iTable;
            pCur.PageID    = -1;
            pCur.KeyInfo   = pKeyInfo;
            pCur.Tree      = this;
            pCur.Shared    = pBt;
            pCur.Writeable = wrFlag;
            pCur.Next      = pBt.Cursors;
            if (pCur.Next != null)
            {
                pCur.Next.Prev = pCur;
            }
            pBt.Cursors       = pCur;
            pCur.State        = CURSOR.INVALID;
            pCur._cachedRowID = 0;
            return(RC.OK);
        }
Ejemplo n.º 6
0
 // was:invalidateOverflowCache
 internal static void invalidateOverflowCache(BtreeCursor cursor)
 {
     Debug.Assert(cursor.HoldsMutex());
     cursor.OverflowIDs = null;
 }
Ejemplo n.º 7
0
 // was:invalidateOverflowCache
 internal static void invalidateOverflowCache(BtreeCursor cursor)
 {
     Debug.Assert(cursor.HoldsMutex());
     cursor.OverflowIDs = null;
 }
Ejemplo n.º 8
0
 // was:sqlite3BtreeCursor
 public RC Cursor(int iTable, bool wrFlag, KeyInfo pKeyInfo, BtreeCursor pCur)
 {
     sqlite3BtreeEnter();
     var rc = btreeCursor(iTable, wrFlag, pKeyInfo, pCur);
     sqlite3BtreeLeave();
     return rc;
 }
Ejemplo n.º 9
0
 internal RC saveAllCursors(Pgno iRoot, BtreeCursor pExcept)
 {
     Debug.Assert(MutexEx.Held(this.Mutex));
     Debug.Assert(pExcept == null || pExcept.Shared == this);
     for (var p = this.Cursors; p != null; p = p.Next)
         if (p != pExcept && (0 == iRoot || p.RootID == iRoot) && p.State == CURSOR.VALID)
         {
             var rc = p.SavePosition();
             if (rc != RC.OK)
                 return rc;
         }
     return RC.OK;
 }
Ejemplo n.º 10
0
 internal RC btreeCursor(int iTable, bool wrFlag, KeyInfo pKeyInfo, BtreeCursor pCur)
 {
     Debug.Assert(sqlite3BtreeHoldsMutex());
     // The following Debug.Assert statements verify that if this is a sharable b-tree database, the connection is holding the required table locks,
     // and that no other connection has any open cursor that conflicts with this lock.
     Debug.Assert(hasSharedCacheTableLock((uint)iTable, (pKeyInfo != null), (wrFlag ? LOCK.READ : LOCK.WRITE)));
     Debug.Assert(!wrFlag || !hasReadConflicts((uint)iTable));
     // Assert that the caller has opened the required transaction.
     Debug.Assert(this.InTransaction > TRANS.NONE);
     Debug.Assert(!wrFlag || this.InTransaction == TRANS.WRITE);
     var pBt = this.Shared;                 // Shared b-tree handle
     Debug.Assert(pBt.Page1 != null && pBt.Page1.Data != null);
     if (Check.NEVER(wrFlag && pBt.ReadOnly))
         return RC.READONLY;
     if (iTable == 1 && pBt.btreePagecount() == 0)
         return RC.EMPTY;
     // Now that no other errors can occur, finish filling in the BtCursor variables and link the cursor into the BtShared list.
     pCur.RootID = (Pgno)iTable;
     pCur.PageID = -1;
     pCur.KeyInfo = pKeyInfo;
     pCur.Tree = this;
     pCur.Shared = pBt;
     pCur.Writeable = wrFlag;
     pCur.Next = pBt.Cursors;
     if (pCur.Next != null)
         pCur.Next.Prev = pCur;
     pBt.Cursors = pCur;
     pCur.State = CURSOR.INVALID;
     pCur._cachedRowID = 0;
     return RC.OK;
 }