SQLite

Check-in [9f39cb5b81]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix "PRAGMA journal_mode" so that if it fails because there is a transaction open, it does not roll that transaction back.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | rollback-abort
Files: files | file ages | folders
SHA3-256: 9f39cb5b8195405f6aafacb04c411ff065ddefd0a234541fa2467f8e03bbcd25
User & Date: dan 2019-01-26 17:47:59.293
Context
2019-01-26
18:10
If a write statement fails with OE_Abort, but there is no statement journal, roll the entire transaction back instead. (check-in: 75a8ed7a42 user: dan tags: rollback-abort)
17:47
Fix "PRAGMA journal_mode" so that if it fails because there is a transaction open, it does not roll that transaction back. (check-in: 9f39cb5b81 user: dan tags: rollback-abort)
16:34
Roll back the transaction if a write statement fails with OE_Abort but there is no open statement transaction. (check-in: d536be698d user: dan tags: rollback-abort)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vacuum.c.
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
    int iIntoReg = 0;
    if( pInto && sqlite3ResolveSelfReference(pParse,0,0,pInto,0)==0 ){
      iIntoReg = ++pParse->nMem;
      sqlite3ExprCode(pParse, pInto, iIntoReg);
    }
    sqlite3VdbeAddOp2(v, OP_Vacuum, iDb, iIntoReg);
    sqlite3VdbeUsesBtree(v, iDb);
    assert( pParse==pParse->pToplevel || pParse->pToplevel==0 );
    pParse->mayAbort = pParse->isMultiWrite = 1;
  }
build_vacuum_end:
  sqlite3ExprDelete(pParse->db, pInto);
  return;
}

/*







<
<







126
127
128
129
130
131
132


133
134
135
136
137
138
139
    int iIntoReg = 0;
    if( pInto && sqlite3ResolveSelfReference(pParse,0,0,pInto,0)==0 ){
      iIntoReg = ++pParse->nMem;
      sqlite3ExprCode(pParse, pInto, iIntoReg);
    }
    sqlite3VdbeAddOp2(v, OP_Vacuum, iDb, iIntoReg);
    sqlite3VdbeUsesBtree(v, iDb);


  }
build_vacuum_end:
  sqlite3ExprDelete(pParse->db, pInto);
  return;
}

/*
Changes to src/vdbeaux.c.
740
741
742
743
744
745
746






747
748
749
750
751
752
753
          break;
        }
#ifndef SQLITE_OMIT_WAL
        case OP_Checkpoint:
#endif
        case OP_Vacuum:
        case OP_JournalMode: {






          p->readOnly = 0;
          p->bIsReader = 1;
          break;
        }
        case OP_Next:
        case OP_SorterNext: {
          pOp->p4.xAdvance = sqlite3BtreeNext;







>
>
>
>
>
>







740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
          break;
        }
#ifndef SQLITE_OMIT_WAL
        case OP_Checkpoint:
#endif
        case OP_Vacuum:
        case OP_JournalMode: {
          /* Neither VACUUM or "PRAGMA journal_mode" statements generate an
          ** OP_Transaction opcode. So setting usesStmtJournal does not cause
          ** either statement to actually open a statement journal. However,
          ** it does prevent them from rolling back an entire transaction
          ** if they fail because there is already a transaction open.  */
          p->usesStmtJournal = 1;
          p->readOnly = 0;
          p->bIsReader = 1;
          break;
        }
        case OP_Next:
        case OP_SorterNext: {
          pOp->p4.xAdvance = sqlite3BtreeNext;
2199
2200
2201
2202
2203
2204
2205
2206
2207

2208
2209
2210
2211
2212
2213
2214
  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode memory used */
  x.pSpace = &((u8*)p->aOp)[n];               /* Unused opcode memory */
  assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) );
  x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused memory */
  assert( x.nFree>=0 );
  assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );

  resolveP2Values(p, &nArg);
  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);

  if( pParse->explain && nMem<10 ){
    nMem = 10;
  }
  p->expired = 0;

  /* Memory for registers, parameters, cursor, etc, is allocated in one or two
  ** passes.  On the first pass, we try to reuse unused memory at the 







<

>







2205
2206
2207
2208
2209
2210
2211

2212
2213
2214
2215
2216
2217
2218
2219
2220
  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode memory used */
  x.pSpace = &((u8*)p->aOp)[n];               /* Unused opcode memory */
  assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) );
  x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused memory */
  assert( x.nFree>=0 );
  assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );


  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
  resolveP2Values(p, &nArg);
  if( pParse->explain && nMem<10 ){
    nMem = 10;
  }
  p->expired = 0;

  /* Memory for registers, parameters, cursor, etc, is allocated in one or two
  ** passes.  On the first pass, we try to reuse unused memory at the