/ Check-in [7619bf47]
Login

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

Overview
Comment:If meta(3)>0 then make the database readonly for now. This allows the current database to interact with future releases that might include autovacuum. (CVS 1888)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7619bf4771781005da23a3e9d7b00de405e27a64
User & Date: drh 2004-08-14 19:20:10
Context
2004-08-17
10:42
Fix a typo in a comment. (CVS 1889) check-in: 9af1d4d1 user: drh tags: trunk
2004-08-14
19:20
If meta(3)>0 then make the database readonly for now. This allows the current database to interact with future releases that might include autovacuum. (CVS 1888) check-in: 7619bf47 user: drh tags: trunk
18:34
Fix a bug that was preventing "PRAGMA temp_store=MEMORY" from working. (CVS 1887) check-in: bb558945 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     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         -** $Id: btree.c,v 1.181 2004/08/08 19:43:30 drh Exp $
           12  +** $Id: btree.c,v 1.182 2004/08/14 19:20:10 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  3742   3742     unsigned char *pP1;
  3743   3743   
  3744   3744     assert( idx>=0 && idx<=15 );
  3745   3745     rc = sqlite3pager_get(pBt->pPager, 1, (void**)&pP1);
  3746   3746     if( rc ) return rc;
  3747   3747     *pMeta = get4byte(&pP1[36 + idx*4]);
  3748   3748     sqlite3pager_unref(pP1);
         3749  +
         3750  +  /* The current implementation is unable to handle writes to an autovacuumed
         3751  +  ** database.  So make such a database readonly. */
         3752  +  if( idx==4 && *pMeta>0 ) pBt->readOnly = 1;
         3753  +
  3749   3754     return SQLITE_OK;
  3750   3755   }
  3751   3756   
  3752   3757   /*
  3753   3758   ** Write meta-information back into the database.  Meta[0] is
  3754   3759   ** read-only and may not be written.
  3755   3760   */

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.250 2004/08/14 18:34:55 drh Exp $
           17  +** $Id: main.c,v 1.251 2004/08/14 19:20:10 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** The following constant value is used by the SQLITE_BIGENDIAN and
................................................................................
   193    193   
   194    194     /* Get the database meta information.
   195    195     **
   196    196     ** Meta values are as follows:
   197    197     **    meta[0]   Schema cookie.  Changes with each schema change.
   198    198     **    meta[1]   File format of schema layer.
   199    199     **    meta[2]   Size of the page cache.
   200         -  **    meta[3]
          200  +  **    meta[3]   Use freelist if 0.  Autovacuum if greater than zero.
   201    201     **    meta[4]   Db text encoding. 1:UTF-8 3:UTF-16 LE 4:UTF-16 BE
   202    202     **    meta[5]
   203    203     **    meta[6]   
   204    204     **    meta[7]
   205    205     **    meta[8]
   206    206     **    meta[9]
   207    207     **

Changes to test/btree.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is btree database backend
    13     13   #
    14         -# $Id: btree.test,v 1.29 2004/06/30 02:35:51 danielk1977 Exp $
           14  +# $Id: btree.test,v 1.30 2004/08/14 19:20:10 drh Exp $
    15     15   
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Basic functionality.  Open and close a database.
    21     21   #
................................................................................
   375    375       btree_update_meta $::b1 0 1 2 3 4 5 6 7 8 9
   376    376     } msg]
   377    377     lappend rc $msg
   378    378   } {1 SQLITE_ERROR}
   379    379   do_test btree-5.3 {
   380    380     btree_begin_transaction $::b1
   381    381     set rc [catch {
   382         -    btree_update_meta $::b1 0 1 2 3 4 5 6 7 8 9
          382  +    btree_update_meta $::b1 0 1 2 3 0 5 6 7 8 9
   383    383     } msg]
   384    384     lappend rc $msg
   385    385   } {0 {}}
   386    386   do_test btree-5.4 {
   387    387     btree_get_meta $::b1
   388         -} {0 1 2 3 4 5 6 7 8 9}
          388  +} {0 1 2 3 0 5 6 7 8 9}
   389    389   do_test btree-5.5 {
   390    390     btree_close_cursor $::c1
   391    391     btree_rollback $::b1
   392    392     btree_get_meta $::b1
   393    393   } {0 0 0 0 0 0 0 0 0 0}
   394    394   do_test btree-5.6 {
   395    395     btree_begin_transaction $::b1
   396         -  btree_update_meta $::b1 0 10 20 30 40 50 60 70 80 90
          396  +  btree_update_meta $::b1 0 10 20 30 0 50 60 70 80 90
   397    397     btree_commit $::b1
   398    398     btree_get_meta $::b1
   399         -} {0 10 20 30 40 50 60 70 80 90}
          399  +} {0 10 20 30 0 50 60 70 80 90}
   400    400   
   401    401   proc select_all {cursor} {
   402    402     set r {}
   403    403     btree_first $cursor
   404    404     while {![btree_eof $cursor]} {
   405    405       set key [btree_key $cursor]
   406    406       lappend r $key