/ Check-in [e98d481d]
Login

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

Overview
Comment:Ensure that if a "ROLLBACK TO" statement is used to rollback (but not close) theoutermost transaction, the xRollbackTo() method of any virtual tables involved in the transaction is invoked.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e98d481d84ef31b6ed154f14deae9b261f722616
User & Date: dan 2015-04-18 16:25:54
Context
2015-04-18
17:43
Fix an incorrect assert() statement in the CREATE INDEX code generator. check-in: 2eed41fd user: drh tags: trunk
16:25
Ensure that if a "ROLLBACK TO" statement is used to rollback (but not close) theoutermost transaction, the xRollbackTo() method of any virtual tables involved in the transaction is invoked. check-in: e98d481d user: dan tags: trunk
04:45
Disregard leading zeros when converting strings to 32-bit integers. check-in: 691cc201 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
          db->nSavepoint--;
        }
      }else{
        db->nDeferredCons = pSavepoint->nDeferredCons;
        db->nDeferredImmCons = pSavepoint->nDeferredImmCons;
      }

      if( !isTransaction ){
        rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
        if( rc!=SQLITE_OK ) goto abort_due_to_error;
      }
    }
  }

  break;







|







2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
          db->nSavepoint--;
        }
      }else{
        db->nDeferredCons = pSavepoint->nDeferredCons;
        db->nDeferredImmCons = pSavepoint->nDeferredImmCons;
      }

      if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){
        rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
        if( rc!=SQLITE_OK ) goto abort_due_to_error;
      }
    }
  }

  break;

Changes to src/vtab.c.

953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
** function immediately. If all calls to virtual table methods are successful,
** SQLITE_OK is returned.
*/
int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
  int rc = SQLITE_OK;

  assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );
  assert( iSavepoint>=0 );
  if( db->aVTrans ){
    int i;
    for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
      VTable *pVTab = db->aVTrans[i];
      const sqlite3_module *pMod = pVTab->pMod->pModule;
      if( pVTab->pVtab && pMod->iVersion>=2 ){
        int (*xMethod)(sqlite3_vtab *, int);







|







953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
** function immediately. If all calls to virtual table methods are successful,
** SQLITE_OK is returned.
*/
int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
  int rc = SQLITE_OK;

  assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );
  assert( iSavepoint>=-1 );
  if( db->aVTrans ){
    int i;
    for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
      VTable *pVTab = db->aVTrans[i];
      const sqlite3_module *pMod = pVTab->pMod->pModule;
      if( pVTab->pVtab && pMod->iVersion>=2 ){
        int (*xMethod)(sqlite3_vtab *, int);

Changes to test/vtab1.test.

1486
1487
1488
1489
1490
1491
1492
1493





































1494

do_test 23.3.1 {
  execsql { CREATE VIRTUAL TABLE t1e USING echo(t2) }
  execsql { INSERT INTO t1e SELECT 4 }
  catchsql { INSERT INTO t1e SELECT eval('DROP TABLE t1e') }
} {1 {database table is locked}}
do_execsql_test 23.3.2 { SELECT * FROM t1e } {1 2 3 4}






































finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531

do_test 23.3.1 {
  execsql { CREATE VIRTUAL TABLE t1e USING echo(t2) }
  execsql { INSERT INTO t1e SELECT 4 }
  catchsql { INSERT INTO t1e SELECT eval('DROP TABLE t1e') }
} {1 {database table is locked}}
do_execsql_test 23.3.2 { SELECT * FROM t1e } {1 2 3 4}

#-------------------------------------------------------------------------
# At one point SQL like this:
#
#   SAVEPOINT xyz;       -- Opens SQL transaction
#     INSERT INTO vtab   -- Write to virtual table
#     ROLLBACK TO xyz;
#   RELEASE xyz;
#
# was not invoking the xRollbackTo() callback for the ROLLBACK TO 
# operation. Which meant that virtual tables like FTS3 would incorrectly 
# commit the results of the INSERT as part of the "RELEASE xyz" command.
#
# The following tests check that this has been fixed.
#
ifcapable fts3 {
  do_execsql_test 24.0 {
    CREATE VIRTUAL TABLE t4 USING fts3();
    SAVEPOINT a;
    INSERT INTO t4 VALUES('a b c');
    ROLLBACK TO a;
    RELEASE a;
    SELECT * FROM t4;
  } {}

  do_execsql_test 24.1 { SELECT * FROM t4 WHERE t4 MATCH 'b' } {}
  do_execsql_test 24.2 { INSERT INTO t4(t4) VALUES('integrity-check') } {}

  do_execsql_test 24.3 {
    SAVEPOINT a;
    CREATE VIRTUAL TABLE t5 USING fts3();
    SAVEPOINT b;
    ROLLBACK TO a;
    SAVEPOINT c;
    RELEASE a;
  }
}

finish_test