Exemplo n.º 1
0
 public static void sqlite3ConnectionBlocked(sqlite3b x, sqlite3b y)
 {
 }
Exemplo n.º 2
0
        // was:sqlite3BtreeBeginTrans
        public RC BeginTrans(byte wrflag)
        {
            var shared = this.Shared;
            var rc = RC.OK;
            sqlite3BtreeEnter();
            btreeIntegrity();
            // If the btree is already in a write-transaction, or it is already in a read-transaction and a read-transaction is requested, this is a no-op.
            if (this.InTransaction == TRANS.WRITE || (this.InTransaction == TRANS.READ && wrflag == 0))
                goto trans_begun;
            // Write transactions are not possible on a read-only database
            if (shared.ReadOnly && wrflag != 0)
            {
                rc = RC.READONLY;
                goto trans_begun;
            }
#if !SQLITE_OMIT_SHARED_CACHE
            // If another database handle has already opened a write transaction on this shared-btree structure and a second write transaction is
            // requested, return SQLITE_LOCKED.
            sqlite3b sharedDB = null;
            if ((wrflag != 0 && shared.InTransaction == TRANS.WRITE) || shared.IsPending)
                sharedDB = shared.Writer.DB;
            else if (wrflag > 1)
                for (var @lock = shared.Locks; @lock != null; @lock = @lock.Next)
                    if (@lock.Tree != this)
                    {
                        sharedDB = @lock.Tree.DB;
                        break;
                    }
            if (sharedDB != null)
            {
                sqlite3b.sqlite3ConnectionBlocked(this.DB, sharedDB);
                rc = RC.LOCKED_SHAREDCACHE;
                goto trans_begun;
            }
#endif
            // Any read-only or read-write transaction implies a read-lock on page 1. So if some other shared-cache client already has a write-lock
            // on page 1, the transaction cannot be opened. */
            rc = querySharedCacheTableLock(MASTER_ROOT, LOCK.READ);
            if (rc != RC.OK)
                goto trans_begun;
            shared.InitiallyEmpty = shared.Pages == 0;
            do
            {
                // Call lockBtree() until either pBt.pPage1 is populated or lockBtree() returns something other than SQLITE_OK. lockBtree()
                // may return SQLITE_OK but leave pBt.pPage1 set to 0 if after reading page 1 it discovers that the page-size of the database
                // file is not pBt.pageSize. In this case lockBtree() will update pBt.pageSize to the page-size of the file on disk.
                while (shared.Page1 == null && (rc = shared.lockBtree()) == RC.OK) ;
                if (rc == RC.OK && wrflag != 0)
                {
                    if (shared.ReadOnly)
                        rc = RC.READONLY;
                    else
                    {
                        rc = shared.Pager.Begin(wrflag > 1, this.DB.sqlite3TempInMemory());
                        if (rc == RC.OK)
                            rc = shared.newDatabase();
                    }
                }
                if (rc != RC.OK)
                    shared.unlockBtreeIfUnused();
            } while (((int)rc & 0xFF) == (int)RC.BUSY && shared.InTransaction == TRANS.NONE && btreeInvokeBusyHandler(shared) != 0);
            if (rc == RC.OK)
            {
                if (this.InTransaction == TRANS.NONE)
                {
                    shared.Transactions++;
#if !SQLITE_OMIT_SHARED_CACHE
                    if (Sharable)
                    {
                        Debug.Assert(Locks.Tree == this && Locks.TableID == 1);
                        Locks.Lock = LOCK.READ;
                        Locks.Next = shared.Locks;
                        shared.Locks = Locks;
                    }
#endif
                }
                this.InTransaction = (wrflag != 0 ? TRANS.WRITE : TRANS.READ);
                if (this.InTransaction > shared.InTransaction)
                    shared.InTransaction = this.InTransaction;
                if (wrflag != 0)
                {
                    var pPage1 = shared.Page1;
#if !SQLITE_OMIT_SHARED_CACHE
                    Debug.Assert(shared.Writer == null);
                    shared.Writer = this;
                    shared.IsExclusive = (wrflag > 1);
#endif
                    // If the db-size header field is incorrect (as it may be if an old client has been writing the database file), update it now. Doing
                    // this sooner rather than later means the database size can safely  re-read the database size from page 1 if a savepoint or transaction
                    // rollback occurs within the transaction.
                    if (shared.Pages != ConvertEx.Get4(pPage1.Data, 28))
                    {
                        rc = Pager.Write(pPage1.DbPage);
                        if (rc == RC.OK)
                            ConvertEx.Put4(pPage1.Data, 28, shared.Pages);
                    }
                }
            }
        trans_begun:
            if (rc == RC.OK && wrflag != 0)
                // This call makes sure that the pager has the correct number of open savepoints. If the second parameter is greater than 0 and
                // the sub-journal is not already open, then it will be opened here.
                rc = shared.Pager.OpenSavepoint(this.DB.nSavepoint);
            btreeIntegrity();
            sqlite3BtreeLeave();
            return rc;
        }
Exemplo n.º 3
0
 public static void sqlite3ConnectionBlocked(sqlite3b x, sqlite3b y)
 {
 }
Exemplo n.º 4
0
 internal static bool sqlite3SchemaMutexHeld(sqlite3b x, int y, ISchema z)
 {
     return(true);
 }
Exemplo n.º 5
0
 internal static bool sqlite3BtreeHoldsAllMutexes(sqlite3b x)
 {
     return(true);
 }
Exemplo n.º 6
0
 internal static bool sqlite3SchemaMutexHeld(sqlite3b x, int y, ISchema z)
 {
     return true;
 }
Exemplo n.º 7
0
 internal static bool sqlite3BtreeHoldsAllMutexes(sqlite3b x)
 {
     return true;
 }