Fix BEGIN IMMEDIATE and BEGIN EXCLUSIVE so that they work even if one or
more of the database files in the connection are read-only. Test cases for this are in TH3. FossilOrigin-Name: 2fa08c3963f008d4723c3f4f4496abcb6d4b575c85ba4a911a6aed5730b5948b
This commit is contained in:
+10
-1
@@ -4657,7 +4657,16 @@ void sqlite3BeginTransaction(Parse *pParse, int type){
|
||||
if( !v ) return;
|
||||
if( type!=TK_DEFERRED ){
|
||||
for(i=0; i<db->nDb; i++){
|
||||
sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);
|
||||
int eTxnType;
|
||||
Btree *pBt = db->aDb[i].pBt;
|
||||
if( pBt && sqlite3BtreeIsReadonly(pBt) ){
|
||||
eTxnType = 0; /* Read txn */
|
||||
}else if( type==TK_EXCLUSIVE ){
|
||||
eTxnType = 2; /* Exclusive txn */
|
||||
}else{
|
||||
eTxnType = 1; /* Write txn */
|
||||
}
|
||||
sqlite3VdbeAddOp2(v, OP_Transaction, i, eTxnType);
|
||||
sqlite3VdbeUsesBtree(v, i);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -3487,7 +3487,8 @@ case OP_AutoCommit: {
|
||||
** active.
|
||||
** If P2 is non-zero, then a write-transaction is started, or if a
|
||||
** read-transaction is already active, it is upgraded to a write-transaction.
|
||||
** If P2 is zero, then a read-transaction is started.
|
||||
** If P2 is zero, then a read-transaction is started. If P2 is 2 or more
|
||||
** then an exclusive transaction is started.
|
||||
**
|
||||
** P1 is the index of the database file on which the transaction is
|
||||
** started. Index 0 is the main database file and index 1 is the
|
||||
@@ -3521,6 +3522,7 @@ case OP_Transaction: {
|
||||
|
||||
assert( p->bIsReader );
|
||||
assert( p->readOnly==0 || pOp->p2==0 );
|
||||
assert( pOp->p2>=0 && pOp->p2<=2 );
|
||||
assert( pOp->p1>=0 && pOp->p1<db->nDb );
|
||||
assert( DbMaskTest(p->btreeMask, pOp->p1) );
|
||||
if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){
|
||||
|
||||
Reference in New Issue
Block a user