/ Check-in [115e19fe]
Login

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

Overview
Comment:Fix for #2415. The progress handler should abandon only the current query, not all active queries. (CVS 4067)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 115e19fe22b9e79fcc400f3a59c80dd9828100e7
User & Date: danielk1977 2007-06-15 14:53:53
Context
2007-06-15
15:08
Fix a test suite bug. To accommadate the fact that handles returned by (db incrblob) change for the second test suite iteration of full.test. (CVS 4068) check-in: 32218834 user: danielk1977 tags: trunk
14:53
Fix for #2415. The progress handler should abandon only the current query, not all active queries. (CVS 4067) check-in: 115e19fe user: danielk1977 tags: trunk
13:57
Do not try to run the fuzz_malloc tests if SQLITE_MEMDEBUG is not enabled. (CVS 4066) check-in: 45211595 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
541
542
543
544
545
546
547

548
549
550
551
552

553


554
555
556
557
558
559
560
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.625 2007/06/13 16:49:49 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <math.h>
#include "vdbeInt.h"

................................................................................
    ** of VDBE ops have been executed (either since this invocation of
    ** sqlite3VdbeExec() or since last time the progress callback was called).
    ** If the progress callback returns non-zero, exit the virtual machine with
    ** a return code SQLITE_ABORT.
    */
    if( db->xProgress ){
      if( db->nProgressOps==nProgressOps ){

        if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
        if( db->xProgress(db->pProgressArg)!=0 ){
          sqlite3_interrupt(db);
        }
        if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;

        CHECK_FOR_INTERRUPT;


        nProgressOps = 0;
      }
      nProgressOps++;
    }
#endif

#ifndef NDEBUG







|







 







>

|
<
<

>
|
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
541
542
543
544
545
546
547
548
549
550


551
552
553
554
555
556
557
558
559
560
561
562
**
** Various scripts scan this source file in order to generate HTML
** documentation, headers files, or other derived files.  The formatting
** of the code in this file is, therefore, important.  See other comments
** in this file for details.  If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
** $Id: vdbe.c,v 1.626 2007/06/15 14:53:53 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <math.h>
#include "vdbeInt.h"

................................................................................
    ** of VDBE ops have been executed (either since this invocation of
    ** sqlite3VdbeExec() or since last time the progress callback was called).
    ** If the progress callback returns non-zero, exit the virtual machine with
    ** a return code SQLITE_ABORT.
    */
    if( db->xProgress ){
      if( db->nProgressOps==nProgressOps ){
        int prc;
        if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
        prc =db->xProgress(db->pProgressArg);


        if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
        if( prc!=0 ){
          rc = SQLITE_INTERRUPT;
          goto vdbe_halt;
        }
        nProgressOps = 0;
      }
      nProgressOps++;
    }
#endif

#ifndef NDEBUG

Changes to src/vdbeaux.c.

1376
1377
1378
1379
1380
1381
1382











1383

1384
1385
1386
1387
1388
1389
1390
      */
      int isReadOnly = 1;
      int isStatement = 0;
      assert(p->aOp || p->nOp==0);
      for(i=0; i<p->nOp; i++){ 
        switch( p->aOp[i].opcode ){
          case OP_Transaction:











            isReadOnly = 0;

            break;
          case OP_Statement:
            isStatement = 1;
            break;
        }
      }
  







>
>
>
>
>
>
>
>
>
>
>
|
>







1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
      */
      int isReadOnly = 1;
      int isStatement = 0;
      assert(p->aOp || p->nOp==0);
      for(i=0; i<p->nOp; i++){ 
        switch( p->aOp[i].opcode ){
          case OP_Transaction:
            /* This is a bit strange. If we hit a malloc() or IO error and
            ** the statement did not open a statement transaction, we will
            ** rollback any active transaction and abort all other active
            ** statements. Or, if this is an SQLITE_INTERRUPT error, we
            ** will only rollback if the interrupted statement was a write.
            **
            ** It could be argued that read-only statements should never
            ** rollback anything. But careful analysis is required before
            ** making this change
            */
            if( p->aOp[i].p2 || mrc!=SQLITE_INTERRUPT ){
              isReadOnly = 0;
            }
            break;
          case OP_Statement:
            isStatement = 1;
            break;
        }
      }
  

Changes to test/progress.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
148
149
150
151
152
153
154
155





















156
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the 'progress callback'.
#
# $Id: progress.test,v 1.7 2007/06/13 16:49:49 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# If the progress callback is not available in this build, skip this
# whole file.
ifcapable !progress {
................................................................................
  db eval {
    SELECT sum(a) FROM t1
  }
} {55}
do_test progress-1.6 {
  set ::rx
} {10}






















finish_test







|







 








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

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the 'progress callback'.
#
# $Id: progress.test,v 1.8 2007/06/15 14:53:53 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# If the progress callback is not available in this build, skip this
# whole file.
ifcapable !progress {
................................................................................
  db eval {
    SELECT sum(a) FROM t1
  }
} {55}
do_test progress-1.6 {
  set ::rx
} {10}

# Check that abandoning a query using the progress handler does
# not cause other queries to abort. Ticket #2415.
do_test progress-1.7 {
  execsql {
    CREATE TABLE abc(a, b, c);
    INSERT INTO abc VALUES(1, 2, 3);
    INSERT INTO abc VALUES(4, 5, 6);
    INSERT INTO abc VALUES(7, 8, 9);
  }

  set ::res [list]
  db eval {SELECT a, b, c FROM abc} {
    lappend ::res $a $b $c
    db progress 10 "expr 1"
    catch {db eval {SELECT a, b, c FROM abc} { }} msg
    lappend ::res $msg
  }

  set ::res
} {1 2 3 interrupted 4 5 6 interrupted 7 8 9 interrupted}

finish_test