/ Check-in [3565fcf8]
Login

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

Overview
Comment:Avoid attempting to call savepoint related methods on deleted sqlite3_vtab objects. Fix for [48f299634a].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3565fcf898960d7a23d23a2f363b039b2e29447b
User & Date: dan 2011-10-29 11:43:04
References
2011-10-29
11:46 Closed ticket [48f29963]: Crash in SAVEPOINT within a transaction that writes to then drops an FTS table plus 2 other changes artifact: 0d0b3bfb user: dan
Context
2011-10-29
12:42
Fix some code formatting in sqlite3Ext.h to avoid lines longer than 80 characters. check-in: 3ec20c30 user: drh tags: trunk
11:43
Avoid attempting to call savepoint related methods on deleted sqlite3_vtab objects. Fix for [48f299634a]. check-in: 3565fcf8 user: dan tags: trunk
01:33
Avoid reporting a NOMEM error if a memory allocation fails while copying the error message from a prepared statement into the database connection. check-in: dcb78793 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vtab.c.

   887    887     assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );
   888    888     assert( iSavepoint>=0 );
   889    889     if( db->aVTrans ){
   890    890       int i;
   891    891       for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
   892    892         VTable *pVTab = db->aVTrans[i];
   893    893         const sqlite3_module *pMod = pVTab->pMod->pModule;
   894         -      if( pMod->iVersion>=2 ){
          894  +      if( pVTab->pVtab && pMod->iVersion>=2 ){
   895    895           int (*xMethod)(sqlite3_vtab *, int);
   896    896           switch( op ){
   897    897             case SAVEPOINT_BEGIN:
   898    898               xMethod = pMod->xSavepoint;
   899    899               pVTab->iSavepoint = iSavepoint+1;
   900    900               break;
   901    901             case SAVEPOINT_ROLLBACK:
................................................................................
   902    902               xMethod = pMod->xRollbackTo;
   903    903               break;
   904    904             default:
   905    905               xMethod = pMod->xRelease;
   906    906               break;
   907    907           }
   908    908           if( xMethod && pVTab->iSavepoint>iSavepoint ){
   909         -          rc = xMethod(db->aVTrans[i]->pVtab, iSavepoint);
          909  +          rc = xMethod(pVTab->pVtab, iSavepoint);
   910    910           }
   911    911         }
   912    912       }
   913    913     }
   914    914     return rc;
   915    915   }
   916    916   

Added test/fts3drop.test.

            1  +# 2011 October 29
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script is testing the FTS3 module. More specifically,
           13  +# that DROP TABLE commands can co-exist with savepoints inside transactions.
           14  +# See ticket [48f299634a] for details.
           15  +#
           16  +
           17  +
           18  +set testdir [file dirname $argv0]
           19  +source $testdir/tester.tcl
           20  +set testprefix fts3drop
           21  +
           22  +# If SQLITE_ENABLE_FTS3 is defined, omit this file.
           23  +ifcapable !fts3 {
           24  +  finish_test
           25  +  return
           26  +}
           27  +
           28  +do_execsql_test 1.1 {
           29  +  CREATE VIRTUAL TABLE f1 USING fts3;
           30  +  INSERT INTO f1 VALUES('a b c');
           31  +}
           32  +
           33  +do_execsql_test 1.2 {
           34  +  BEGIN;
           35  +    INSERT INTO f1 VALUES('d e f');
           36  +    SAVEPOINT one;
           37  +      INSERT INTO f1 VALUES('g h i');
           38  +      DROP TABLE f1;
           39  +    ROLLBACK TO one;
           40  +  COMMIT;
           41  +}
           42  +
           43  +do_execsql_test 1.3 {
           44  +  SELECT * FROM f1;
           45  +} {{a b c} {d e f}}
           46  +
           47  +do_execsql_test 1.4 {
           48  +  BEGIN;
           49  +    INSERT INTO f1 VALUES('g h i');
           50  +    SAVEPOINT one;
           51  +      INSERT INTO f1 VALUES('j k l');
           52  +      DROP TABLE f1;
           53  +    RELEASE one;
           54  +  ROLLBACK;
           55  +}
           56  +
           57  +do_execsql_test 1.5 {
           58  +  SELECT * FROM f1;
           59  +} {{a b c} {d e f}}
           60  +
           61  +finish_test