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

Overview
Comment:Fix some test cases to account for sqlite4 memory mapping the file.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | prefix-mmap
Files: files | file ages | folders
SHA1: 5f9133f8a8bbf81232f400bcf5d56c01b8e8107a
User & Date: dan 2013-03-07 20:12:15.804
Context
2013-03-08
09:59
Merge prefix-mmap branch with trunk. This allows lsm to memory map a prefix of the database file and use regular read and write system calls to access the remainder. check-in: 02954a5b8d user: dan tags: trunk
2013-03-07
20:12
Fix some test cases to account for sqlite4 memory mapping the file. Leaf check-in: 5f9133f8a8 user: dan tags: prefix-mmap
19:54
Fix a compressed database mode bug. check-in: 84e9aca245 user: dan tags: prefix-mmap
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/log3.test.
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
reset_db
do_test 2.0 { sqlite4_lsm_config db main safety   2    } {2}

do_execsql_test 2.2 {
  CREATE TABLE t1(a PRIMARY KEY, b);
  INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
} {}
do_filesize_test 2.3   0 1024

do_execsql_test 2.4 {
  BEGIN;
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
  COMMIT;
} {}
do_filesize_test 2.5   0 2048

do_test         2.6 { optimize_db } {}
do_execsql_test 2.7 { INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50)) }
do_test         2.8 { sqlite4_lsm_checkpoint db main } {}
do_test 2.9 { sqlite4_lsm_info db main log-structure } {0 0 0 0 2560 3072}

for {set i 1} {$i <= 6} {incr i} {







|











|







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
reset_db
do_test 2.0 { sqlite4_lsm_config db main safety   2    } {2}

do_execsql_test 2.2 {
  CREATE TABLE t1(a PRIMARY KEY, b);
  INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
} {}
do_filesize_test 2.3   262144 1024

do_execsql_test 2.4 {
  BEGIN;
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));
  COMMIT;
} {}
do_filesize_test 2.5   262144 2048

do_test         2.6 { optimize_db } {}
do_execsql_test 2.7 { INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50)) }
do_test         2.8 { sqlite4_lsm_checkpoint db main } {}
do_test 2.9 { sqlite4_lsm_info db main log-structure } {0 0 0 0 2560 3072}

for {set i 1} {$i <= 6} {incr i} {
Changes to test/lsm5.test.
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
set testprefix lsm5
db close

# Create a new database with file name $file.
#
proc create_abc_db {file} {
  forcedelete $file
  lsm_open db $file {block_size 256}
  db write a alpha
  db write b bravo
  db write c charlie
  db close
}

proc create_abc_log {file} {
  forcedelete $file ${file}-2
  lsm_open db ${file}-2
  db write a alpha
  db write b bravo
  db write c charlie
  file copy ${file}-2 $file
  file copy ${file}-2-log $file-log
  db close
}

#-------------------------------------------------------------------------
# When the database system is shut down (i.e. when the last connection
# disconnects), an attempt is made to truncate the database file to the
# minimum number of blocks required.
# 
# This test case checks that this process does not actually cause the
# database to grow.
# 
do_test 1.1 {
  lsm_open db test.db
  db config {mmap 0}
} {0}
do_test 1.2 {
  db write 1 one
  db write 2 two
  db close
} {}
do_test 1.3 {
  expr [file size test.db] < (64*1024)







|








|

















|
<
|







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
set testprefix lsm5
db close

# Create a new database with file name $file.
#
proc create_abc_db {file} {
  forcedelete $file
  lsm_open db $file {block_size 256 mmap 0}
  db write a alpha
  db write b bravo
  db write c charlie
  db close
}

proc create_abc_log {file} {
  forcedelete $file ${file}-2
  lsm_open db ${file}-2 {mmap 0}
  db write a alpha
  db write b bravo
  db write c charlie
  file copy ${file}-2 $file
  file copy ${file}-2-log $file-log
  db close
}

#-------------------------------------------------------------------------
# When the database system is shut down (i.e. when the last connection
# disconnects), an attempt is made to truncate the database file to the
# minimum number of blocks required.
# 
# This test case checks that this process does not actually cause the
# database to grow.
# 
do_test 1.1 {
  lsm_open db test.db {mmap 0}

} {db}
do_test 1.2 {
  db write 1 one
  db write 2 two
  db close
} {}
do_test 1.3 {
  expr [file size test.db] < (64*1024)
Changes to test/mc1.test.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  # Test that connection 2 can see changes made by connection 1.
  do_test 1.$tn.1 { 
    sql1 { CREATE TABLE t1(a PRIMARY KEY, b) } 
    sql1 { INSERT INTO t1 VALUES(1, 2) }
    sql2 { SELECT * FROM t1 }
  } {1 2}

  do_test 1.$tn.2 { file size test.db } 0

  # Connection 1 does not see uncommitted changes made by connection 2.
  do_test 1.$tn.3 {
    sql2 { BEGIN; INSERT INTO t1 VALUES(2, 4); }
    sql1 { SELECT * FROM t1 }
  } {1 2}








|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  # Test that connection 2 can see changes made by connection 1.
  do_test 1.$tn.1 { 
    sql1 { CREATE TABLE t1(a PRIMARY KEY, b) } 
    sql1 { INSERT INTO t1 VALUES(1, 2) }
    sql2 { SELECT * FROM t1 }
  } {1 2}

  do_test 1.$tn.2 { file size test.db } [expr 256*1024]

  # Connection 1 does not see uncommitted changes made by connection 2.
  do_test 1.$tn.3 {
    sql2 { BEGIN; INSERT INTO t1 VALUES(2, 4); }
    sql1 { SELECT * FROM t1 }
  } {1 2}

71
72
73
74
75
76
77
78
79
80
81
82
  # But it can from a new snapshot.
  do_test 1.$tn.9 {
    sql1  { COMMIT; BEGIN }
    sql1  { INSERT INTO t1 VALUES(6, 12) }
    sql1  { SELECT * FROM t1 }
  } {1 2 2 4 3 6 4 8 5 10 6 12}

  do_test 1.$tn.10 { file size test.db } 0
}

finish_test








|




71
72
73
74
75
76
77
78
79
80
81
82
  # But it can from a new snapshot.
  do_test 1.$tn.9 {
    sql1  { COMMIT; BEGIN }
    sql1  { INSERT INTO t1 VALUES(6, 12) }
    sql1  { SELECT * FROM t1 }
  } {1 2 2 4 3 6 4 8 5 10 6 12}

  do_test 1.$tn.10 { file size test.db } [expr 256*1024]
}

finish_test

Changes to test/simple.test.
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
  INSERT INTO t1 SELECT randomblob(1024) FROM t1;    --  64
}
do_execsql_test 71.2 { SELECT count(*) FROM t1 } 64
db close
sqlite4 db test.db
do_execsql_test 71.3 { SELECT count(*) FROM t1 } 64
do_test 71.4 { 
  expr {[file size test.db] < 256*1024}
} {1}

#-------------------------------------------------------------------------
# This is testing that the "phantom" runs feature works with mmap.
#
# UPDATE: Said feature was dropped early in development. But the test 
# remains valid.







|







1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
  INSERT INTO t1 SELECT randomblob(1024) FROM t1;    --  64
}
do_execsql_test 71.2 { SELECT count(*) FROM t1 } 64
db close
sqlite4 db test.db
do_execsql_test 71.3 { SELECT count(*) FROM t1 } 64
do_test 71.4 { 
  expr {[file size test.db] <= 256*1024}
} {1}

#-------------------------------------------------------------------------
# This is testing that the "phantom" runs feature works with mmap.
#
# UPDATE: Said feature was dropped early in development. But the test 
# remains valid.