SQLite

Check-in [535155be58]
Login

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

Overview
Comment:Fix a problem causing spurious SQLITE_CORRUPT errors when using the snapshot API to read from old database snapshots.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 535155be584ad8c1836e6b1c62de836d9872056d39608c995221c928cb5b365d
User & Date: dan 2018-08-28 11:23:52.641
Context
2018-08-28
15:51
Fix new issues in the geopoly module discovered by TH3. (check-in: 22fff9afc2 user: drh tags: trunk)
11:23
Fix a problem causing spurious SQLITE_CORRUPT errors when using the snapshot API to read from old database snapshots. (check-in: 535155be58 user: dan tags: trunk)
2018-08-27
17:13
Add support for the Geopoly extension to the R-Tree extension. This also involves adding the SQLITE_INDEX_CONSTRAINT_FUNCTION capability to the xFindFunction method of the sqlite3_module object, and to the sqlite3_index_info.aConstraint.op field in the xBestIndex implementation of virtual tables. (check-in: 666133e32c user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/wal.c.
2794
2795
2796
2797
2798
2799
2800

2801
2802
2803
2804
2805
2806
2807
          *pChanged = bChanged;
        }else{
          rc = SQLITE_BUSY_SNAPSHOT;
        }

        /* Release the shared CKPT lock obtained above. */
        walUnlockShared(pWal, WAL_CKPT_LOCK);

      }


      if( rc!=SQLITE_OK ){
        sqlite3WalEndReadTransaction(pWal);
      }
    }







>







2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
          *pChanged = bChanged;
        }else{
          rc = SQLITE_BUSY_SNAPSHOT;
        }

        /* Release the shared CKPT lock obtained above. */
        walUnlockShared(pWal, WAL_CKPT_LOCK);
        pWal->minFrame = 1;
      }


      if( rc!=SQLITE_OK ){
        sqlite3WalEndReadTransaction(pWal);
      }
    }
Added test/snapshot4.test.






















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 2018 August 28
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    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 the sqlite3_snapshot_xxx() APIs.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !snapshot {finish_test; return}
set testprefix snapshot4

# This test does not work with the inmemory_journal permutation. The reason
# is that each connection opened as part of this permutation executes
# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
# and there are one or more existing connections.
if {[permutation]=="inmemory_journal"} {
  finish_test
  return
}

sqlite3 db2 test.db

do_execsql_test 1.0 {
  PRAGMA cache_size = 10;
  CREATE TABLE t1(a, b);
  INSERT INTO t1 VALUES(1, randomblob(400));
  PRAGMA journal_mode = wal;
  WITH s(i) AS (
    SELECT 2 UNION ALL SELECT i+1 FROM s WHERE i<100
  ) 
  INSERT INTO t1 SELECT i, randomblob(400) FROM s;
} {wal}

do_test 1.1 {
  execsql {
    BEGIN;
      SELECT count(*) FROM t1;
  }
} {100}

do_test 1.2 {
  db2 eval { 
    SELECT count(*) FROM t1;
    CREATE TABLE t2(x); 
  }
} {100}

do_test 1.3 {
  set ::snap [sqlite3_snapshot_get_blob db main]
  db2 eval { PRAGMA wal_checkpoint }
} {0 54 52}

do_test 1.4 {
  execsql {
    COMMIT;
    SELECT * FROM sqlite_master;
    BEGIN;
  }
  sqlite3_snapshot_open_blob db main $::snap
  execsql {
    SELECT count(*) FROM t1
  } 
} {100}


finish_test