/ Check-in [efd7bcb3]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Make sure the database schema has been read before compiling an incrmental_vacuum pragma. (CVS 4032)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: efd7bcb34c1b4a0a3d4b954b90dfee93ac87bc86
User & Date: danielk1977 2007-05-23 13:50:24
Context
2007-05-23
16:23
Add some code to MemTranslate() to prevent the READ_UTF8() macro from overreading a buffer. (CVS 4033) check-in: 0595319c user: danielk1977 tags: trunk
13:50
Make sure the database schema has been read before compiling an incrmental_vacuum pragma. (CVS 4032) check-in: efd7bcb3 user: danielk1977 tags: trunk
13:34
Fix a leaked page reference that could occur after an IO error in auto-vacuum databases. Also modify incrvacuum.test to work with DEFAULT_AUTOVACUUM=1 builds. (CVS 4031) check-in: e691f2fa user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.138 2007/05/11 12:30:04 drh Exp $
           14  +** $Id: pragma.c,v 1.139 2007/05/23 13:50:24 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "os.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /* Ignore this whole file if pragmas are disabled
    21     21   */
................................................................................
   441    441     **  PRAGMA [database.]incremental_vacuum(N)
   442    442     **
   443    443     ** Do N steps of incremental vacuuming on a database.
   444    444     */
   445    445   #ifndef SQLITE_OMIT_AUTOVACUUM
   446    446     if( sqlite3StrICmp(zLeft,"incremental_vacuum")==0 ){
   447    447       int iLimit, addr;
          448  +    if( sqlite3ReadSchema(pParse) ){
          449  +      goto pragma_out;
          450  +    }
   448    451       if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){
   449    452         iLimit = 0x7fffffff;
   450    453       }
   451    454       sqlite3BeginWriteOperation(pParse, 0, iDb);
   452    455       sqlite3VdbeAddOp(v, OP_MemInt, iLimit, 0);
   453    456       addr = sqlite3VdbeAddOp(v, OP_IncrVacuum, iDb, 0);
   454    457       sqlite3VdbeAddOp(v, OP_Callback, 0, 0);

Changes to test/incrvacuum.test.

    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the incremental vacuum feature.
    13     13   #
    14     14   # Note: There are also some tests for incremental vacuum and IO 
    15     15   # errors in incrvacuum_ioerr.test.
    16     16   #
    17         -# $Id: incrvacuum.test,v 1.7 2007/05/23 13:34:32 danielk1977 Exp $
           17  +# $Id: incrvacuum.test,v 1.8 2007/05/23 13:50:24 danielk1977 Exp $
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # If this build of the library does not support auto-vacuum, omit this
    23     23   # whole file.
    24     24   ifcapable {!autovacuum || !pragma} {
................................................................................
   431    431         SELECT * FROM tbl1;
   432    432       }
   433    433     } {hello world}
   434    434   
   435    435     if {$::nRow == $::iWrite} break
   436    436     incr ::iWrite
   437    437   }
          438  +
          439  +#---------------------------------------------------------------------
          440  +# This test - incrvacuum-8.* - is to check that nothing goes wrong
          441  +# with an incremental-vacuum if it is the first statement executed
          442  +# after an existing database is opened.
          443  +#
          444  +# At one point, this would always return SQLITE_SCHEMA (which 
          445  +# causes an infinite loop in tclsqlite.c if using the Tcl interface).
          446  +#
          447  +do_test incrvacuum-8.1 {
          448  +  db close
          449  +  sqlite3 db test.db
          450  +  execsql {
          451  +    PRAGMA incremental_vacuum(50);
          452  +  }
          453  +} {}
   438    454   
   439    455   finish_test