SQLite

Changes On Branch f2fs-test-fixes
Login

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

Changes In Branch f2fs-test-fixes Excluding Merge-Ins

This is equivalent to a diff from bb196fcb to c3dc7b8d

2018-01-13
14:02
Fix various problems in test scripts preventing "make test" from passing on F2FS file-systems with the "atomic-write" feature. (check-in: 6bedc743 user: dan tags: trunk)
14:01
Fix a typo in crash8.test. (Closed-Leaf check-in: c3dc7b8d user: dan tags: f2fs-test-fixes)
13:07
Fix various problems in test scripts preventing "make test" from passing on F2FS file-systems with the "atomic-write" feature. (check-in: 56d93d07 user: dan tags: f2fs-test-fixes)
02:07
Updates and minor typo fix for the README. (check-in: bb196fcb user: mistachkin tags: trunk)
01:53
Add the new "nochange" APIs to the extension loading mechanism. (check-in: cd7c4269 user: drh tags: trunk)

Changes to test/crash8.test.

138
139
140
141
142
143
144

145
146
147
148
149
150
151
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152







+







# Also test that SQLite will not rollback a hot-journal file with a
# suspect page-size. In this case "suspect" means:
# 
#    a) Not a power of 2, or
#    b) Less than 512, or
#    c) Greater than SQLITE_MAX_PAGE_SIZE
#
if {[atomic_batch_write test.db]==0} {
do_test crash8-3.1 {
  list [file exists test.db-joural] [file exists test.db]
} {0 1}
do_test crash8-3.2 {
  execsql {
    PRAGMA synchronous = off;
    BEGIN;
224
225
226
227
228
229
230

231
232
233
234
235
236
237
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239







+







  puts -nonewline $fd $zJournal
  close $fd
  execsql { 
    SELECT count(*) FROM t1;
    PRAGMA integrity_check
  }
} {6 ok}
}


# If a connection running in persistent-journal mode is part of a 
# multi-file transaction, it must ensure that the master-journal name
# appended to the journal file contents during the commit is located
# at the end of the physical journal file. If there was already a
# large journal file allocated at the start of the transaction, this
262
263
264
265
266
267
268



269
270



271
272
273
274
275
276
277
264
265
266
267
268
269
270
271
272
273


274
275
276
277
278
279
280
281
282
283







+
+
+
-
-
+
+
+







      PRAGMA aux.journal_mode = persist;
      CREATE TABLE aux.ab(a, b);
      INSERT INTO aux.ab SELECT * FROM main.ab;

      UPDATE aux.ab SET b = randstr(1000,1000) WHERE a>=1;
      UPDATE ab SET b = randstr(1000,1000) WHERE a>=1;
    }
  } {persist persist}
  if {[atomic_batch_write test.db]==0} {
    do_test crash8.4.1.1 {
    list [file exists test.db-journal] [file exists test2.db-journal]
  } {1 1}
      list [file exists test.db-journal] [file exists test2.db-journal]
    } {1 1}
  }

  do_test crash8-4.2 {
    execsql {
      BEGIN;
        UPDATE aux.ab SET b = 'def' WHERE a = 0;
        UPDATE main.ab SET b = 'def' WHERE a = 0;
      COMMIT;

Changes to test/delete_db.test.

12
13
14
15
16
17
18





19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30







+
+
+
+
+







# focus of this file is testing the code in test_delete.c (the
# sqlite3_delete_database() API).
#

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

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

proc delete_all {} {
  foreach f [glob -nocomplain test2*] { file delete $f }
  foreach f [glob -nocomplain test3*] { file delete $f }
}

proc copydb {} {

Changes to test/exclusive.test.

248
249
250
251
252
253
254
255



256
257
258
259
260
261
262
248
249
250
251
252
253
254

255
256
257
258
259
260
261
262
263
264







-
+
+
+







# truncates instead of deletes the journal file when committing 
# a transaction.
#
# These tests are not run on windows because the windows backend
# opens the journal file for exclusive access, preventing its contents 
# from being inspected externally.
#
if {$tcl_platform(platform) != "windows"} {
if {$tcl_platform(platform) != "windows"
 && [atomic_batch_write test.db]==0
} {

  # Return a list of two booleans (either 0 or 1). The first is true
  # if the named file exists. The second is true only if the file
  # exists and the first 28 bytes contain at least one non-zero byte.
  #
  proc filestate {fname} {
    set exists 0
387
388
389
390
391
392
393

394
395
396
397
398
399
400
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403







+







  }
} {normal}

#----------------------------------------------------------------------
# Tests exclusive-5.X - test that statement journals are truncated
# instead of deleted when in exclusive access mode.
#
if {[atomic_batch_write test.db]==0} {

# Close and reopen the database so that the temp database is no
# longer active.
#
db close
sqlite3 db test.db

503
504
505
506
507
508
509
510


511
506
507
508
509
510
511
512
513
514
515
516








+
+

  sqlite3 db test.db
} {}

do_execsql_test exclusive-6.5 {
  PRAGMA locking_mode = EXCLUSIVE;
  SELECT * FROM sqlite_master;
} {exclusive}

} ;# atomic_batch_write==0

finish_test

Changes to test/fallocate.test.

57
58
59
60
61
62
63

64
65
66
67
68
69
70
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







+







# causes a database file to grow, the database grows to its previous size
# on disk, not to the minimum size required to hold the database image.
#
do_test fallocate-1.7 {
  execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }
  if {[permutation] != "inmemory_journal"
   && [permutation] != "atomic-batch-write"
   && [atomic_batch_write test.db]==0
  } {
    hexio_get_int [hexio_read test.db-journal 16 4]
  } else {
    set {} 1024
  }
} {1024}
do_test fallocate-1.8 { execsql { COMMIT } } {}

Changes to test/journal1.test.

18
19
20
21
22
23
24



25



26
27
28
29
30
31
32
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37







+
+
+
-
+
+
+








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

# These tests will not work on windows because windows uses
# manditory file locking which breaks the copy_file command.
#
# Or with atomic_batch_write systems, as journal files are
# not created.
#
if {$tcl_platform(platform)=="windows"} {
if {$tcl_platform(platform)=="windows"
 || [atomic_batch_write test.db]
} {
  finish_test
  return
}

# Create a smaple database
#
do_test journal1-1.1 {

Changes to test/journal3.test.

16
17
18
19
20
21
22
23



24
25
26
27
28
29
30
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32







-
+
+
+







source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl

#-------------------------------------------------------------------------
# If a connection is required to create a journal file, it creates it with 
# the same file-system permissions as the database file itself. Test this.
#
if {$::tcl_platform(platform) == "unix"} {
if {$::tcl_platform(platform) == "unix"
 && [atomic_batch_write test.db]==0
} {

  # Changed on 2012-02-13:  umask is deliberately ignored for -wal, -journal,
  # and -shm files.
  #set umask [exec /bin/sh -c umask]
  faultsim_delete_and_reopen
  do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}

Changes to test/jrnlmode.test.

298
299
300
301
302
303
304

305
306
307
308
309
310
311
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312







+







  integrity_check jrnlmode-4.5
}

#------------------------------------------------------------------------
# The following test caes, jrnlmode-5.*, test the journal_size_limit
# pragma.
ifcapable pragma {
if {[atomic_batch_write test.db]==0} {
  db close
  forcedelete test.db test2.db test3.db
  sqlite3 db test.db

  do_test jrnlmode-5.1 {
    execsql {pragma page_size=1024}
    execsql {pragma journal_mode=persist}
450
451
452
453
454
455
456
457


458

459
460
461
462
463
464
465
451
452
453
454
455
456
457

458
459
460
461
462
463
464
465
466
467
468







-
+
+

+







    expr {[file size test.db-journal] > 1024}
  } {1}
  do_test jrnlmode-5.22 {
    execsql COMMIT
    list [file exists test.db-journal] [file size test.db-journal]
  } {1 0}
}

}

ifcapable pragma {
if {[atomic_batch_write test.db]==0} {
  # These tests are not run as part of the "journaltest" permutation,
  # as the test_journal.c layer is incompatible with in-memory journaling.
  if {[permutation] ne "journaltest"} {

    do_test jrnlmode-6.1 {
      execsql {
        PRAGMA journal_mode = truncate;
502
503
504
505
506
507
508

509
510
511
512
513
514
515
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519







+







      execsql {
        PRAGMA journal_mode = DELETE;
        BEGIN IMMEDIATE; INSERT INTO t4 VALUES(1,2); COMMIT;
      }
      file exists test.db-journal
    } {0}
  }
}
}

ifcapable pragma {
  catch { db close }
  do_test jrnlmode-7.1 {
    foreach f [glob -nocomplain test.db*] { forcedelete $f }
    sqlite3 db test.db

Changes to test/jrnlmode2.test.

13
14
15
16
17
18
19





20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31







+
+
+
+
+







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

ifcapable {!pager_pragmas} {
  finish_test
  return
}

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

#-------------------------------------------------------------------------
# The tests in this file check that the following two bugs (both now fixed)
# do not reappear.
#
# jrnlmode2-1.*: Demonstrate bug #3745:
#

Changes to test/lock4.test.

12
13
14
15
16
17
18








19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33







+
+
+
+
+
+
+
+







# focus of this script is database locks.
#
# $Id: lock4.test,v 1.10 2009/05/06 00:52:41 drh Exp $


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

if {[atomic_batch_write test.db]} {
  # This test uses two processes, one of which blocks until the other
  # creates a *-journal file. Which doesn't work if atomic writes are
  # available.
  finish_test
  return
}

do_not_use_codec

# Initialize the test.db database so that it is non-empty
#
do_test lock4-1.1 {
  db eval {

Changes to test/pager1.test.

12
13
14
15
16
17
18





19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30







+
+
+
+
+








set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl
source $testdir/wal_common.tcl
set testprefix pager1

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
#
do_not_use_codec

#

Changes to test/pager3.test.

12
13
14
15
16
17
18




19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+
+








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

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

foreach {tn sql res j} {
  1 "PRAGMA journal_mode = DELETE"  delete        0
  2 "CREATE TABLE t1(a, b)"         {}            0
  3 "PRAGMA locking_mode=EXCLUSIVE" {exclusive}   0
  4 "INSERT INTO t1 VALUES(1, 2)"   {}            1
  5 "PRAGMA locking_mode=NORMAL"    {normal}      1

Changes to test/rollback.test.

79
80
81
82
83
84
85

86
87
88
89
90
91
92
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93







+







  sqlite3_finalize $STMT
} {SQLITE_OK}

if {$tcl_platform(platform) == "unix" 
 && [permutation] ne "onefile"
 && [permutation] ne "inmemory_journal"
 && [permutation] ne "atomic-batch-write"
 && [atomic_batch_write test.db]==0
} {
  do_test rollback-2.1 {
    execsql {
      BEGIN;
      INSERT INTO t3 VALUES('hello world');
    }
    forcecopy test.db testA.db

Changes to test/sharedA.test.

14
15
16
17
18
19
20





21
22
23
24
25
26
27
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32







+
+
+
+
+









set testdir [file dirname $argv0]
source $testdir/tester.tcl
if {[run_thread_tests]==0} { finish_test ; return }
db close
set ::testprefix sharedA

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

set ::enable_shared_cache [sqlite3_enable_shared_cache 1]

#-------------------------------------------------------------------------
#
do_test 0.1 {
  sqlite3 db1 test.db

Changes to test/stmt.test.

11
12
13
14
15
16
17





18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+
+
+
+
+







#
# The tests in this file check that SQLite uses (or does not use) a
# statement journal for various SQL statements.
#

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

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

do_test stmt-1.1 {
  execsql { CREATE TABLE t1(a integer primary key, b INTEGER NOT NULL) }
} {}

# The following tests verify the method used for the tests in this file -
# that if a statement journal is required by a statement it is opened and

Changes to test/symlink.test.

98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112







-
+







  } 0
  do_test 2.$tn.2 {
    execsql {
      BEGIN;
        INSERT INTO t1 VALUES(1);
    } db2
    file exists test.db-journal
  } 1
  } [expr [atomic_batch_write test.db]==0]
  do_test 2.$tn.3 {
    list [file exists test2.db-journal] [file exists test3.db-journal]
  } {0 0}
  do_test 2.$tn.4 {
    execsql {
      COMMIT;
      PRAGMA journal_mode = wal;

Changes to test/sync.test.

21
22
23
24
25
26
27




28
29
30
31
32
33
34
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38







+
+
+
+







# These tests are only applicable when pager pragma are
# enabled. Also, since every test uses an ATTACHed database, they
# are only run when ATTACH is enabled.
#
ifcapable !pager_pragmas||!attach {
  finish_test
  return
}
if {[atomic_batch_write test.db]} {
  finish_test
  return
}

set sqlite_sync_count 0
proc cond_incr_sync_count {adj} {
  global sqlite_sync_count
  if {$::tcl_platform(platform) == "windows"} {
    incr sqlite_sync_count $adj

Changes to test/sync2.test.

25
26
27
28
29
30
31

32
33
34
35
36
37
38
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39







+







ifcapable !pager_pragmas||!attach||!dirsync {
  finish_test
  return
}
if {$::tcl_platform(platform)!="unix" 
  || [permutation] == "journaltest"
  || [permutation] == "inmemory_journal"
  || [atomic_batch_write test.db] 
} {
  finish_test
  return
}

proc execsql_sync {sql} {
  set s $::sqlite_sync_count

Changes to test/tempdb.test.

12
13
14
15
16
17
18





19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30







+
+
+
+
+







# The focus of this file is in making sure that rolling back
# a statement journal works correctly.
#
# $Id: tempdb.test,v 1.4 2009/06/05 17:09:12 drh Exp $

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

if {[atomic_batch_write test.db]} {
  finish_test
  return
}

# Use a temporary database.
#
db close
sqlite3 db {}

# Force a statement journal rollback on a database file that

Changes to test/tkt3457.test.

14
15
16
17
18
19
20




21
22
23
24
25
26
27
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31







+
+
+
+








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

if {$tcl_platform(platform) != "unix"} {
  finish_test
  return
}
if {[atomic_batch_write test.db]} {
  finish_test
  return
}

#-----------------------------------------------------------------------
# To roll back a hot-journal file, the application needs read and write 
# permission on the journal file in question. The following tests test
# the outcome of trying to rollback a hot-journal file when this is not
# the case.

Changes to test/vacuum5.test.

139
140
141
142
143
144
145

146
147
148




149
150
151
152
153
139
140
141
142
143
144
145
146



147
148
149
150
151
152
153
154
155







+
-
-
-
+
+
+
+





    INSERT INTO t1 SELECT NULL, randomblob(100) FROM s;
  }

  do_execsql_test 3.1 { VACUUM }

  db close
  tvfs delete
  if {[atomic_batch_write test.db]==0} {
  do_test 3.2 {
    lrange $::openfiles 0 4
  } {test.db test.db-journal test.db-journal {} test.db-journal}
    do_test 3.2 {
      lrange $::openfiles 0 4
    } {test.db test.db-journal test.db-journal {} test.db-journal}
  }
} 



finish_test

Changes to test/wal2.test.

580
581
582
583
584
585
586



587
588



589
590
591
592
593



594
595



596
597
598
599
600
601
602
580
581
582
583
584
585
586
587
588
589


590
591
592
593
594
595
596
597
598
599
600


601
602
603
604
605
606
607
608
609
610







+
+
+
-
-
+
+
+





+
+
+
-
-
+
+
+







  execsql { PRAGMA lock_status }
} {main exclusive temp closed}
do_test wal2-6.3.4 {
  execsql { 
    BEGIN;
      INSERT INTO t1 VALUES('Groucho');
  }
} {}
if {[atomic_batch_write test.db]==0} {
  do_test wal2-6.3.4.1 {
  list [file exists test.db-wal] [file exists test.db-journal]
} {0 1}
    list [file exists test.db-wal] [file exists test.db-journal]
  } {0 1}
}
do_test wal2-6.3.5 {
  execsql { PRAGMA lock_status }
} {main exclusive temp closed}
do_test wal2-6.3.6 {
  execsql { COMMIT }
} {}
if {[atomic_batch_write test.db]==0} {
  do_test wal2-6.3.6.1 {
  list [file exists test.db-wal] [file exists test.db-journal]
} {0 1}
    list [file exists test.db-wal] [file exists test.db-journal]
  } {0 1}
}
do_test wal2-6.3.7 {
  execsql { PRAGMA lock_status }
} {main exclusive temp closed}
db close


# This test - wal2-6.4.* - uses a single database connection and the

Changes to test/walmode.test.

41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56










57
58
59
60
61
62
63
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







+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+







  execsql { PRAGMA page_size = 1024 }
  execsql { PRAGMA journal_mode = wal }
} {wal}
do_test walmode-1.2 {
  file size test.db
} {1024}

if {[atomic_batch_write test.db]==0} {
set expected_sync_count 3
if {$::tcl_platform(platform)!="windows"} {
  ifcapable dirsync {
    incr expected_sync_count
  }
}
do_test walmode-1.3 {
  set sqlite_sync_count
} $expected_sync_count
  set expected_sync_count 3
  if {$::tcl_platform(platform)!="windows"} {
    ifcapable dirsync {
      incr expected_sync_count
    }
  }
  do_test walmode-1.3 {
    set sqlite_sync_count
  } $expected_sync_count
}

do_test walmode-1.4 {
  file exists test.db-wal
} {0}
do_test walmode-1.5 {
  execsql { CREATE TABLE t1(a, b) }
  file size test.db
102
103
104
105
106
107
108

109
110
111




112
113
114
115
116
117
118
119

120
121
122




123
124
125
126
127
128
129
104
105
106
107
108
109
110
111



112
113
114
115
116
117
118
119
120
121
122
123
124



125
126
127
128
129
130
131
132
133
134
135







+
-
-
-
+
+
+
+








+
-
-
-
+
+
+
+








# Test that changing back to journal_mode=persist works.
#
do_test walmode-4.1 {
  execsql { INSERT INTO t1 VALUES(1, 2) }
  execsql { PRAGMA journal_mode = persist }
} {persist}
if {[atomic_batch_write test.db]==0} {
do_test walmode-4.2 {
  list [file exists test.db-journal] [file exists test.db-wal]
} {1 0}
  do_test walmode-4.2 {
    list [file exists test.db-journal] [file exists test.db-wal]
  } {1 0}
}
do_test walmode-4.3 {
  execsql { SELECT * FROM t1 }
} {1 2}
do_test walmode-4.4 {
  db close
  sqlite3 db test.db
  execsql { SELECT * FROM t1 }
} {1 2}
if {[atomic_batch_write test.db]==0} {
do_test walmode-4.5 {
  list [file exists test.db-journal] [file exists test.db-wal]
} {1 0}
  do_test walmode-4.5 {
    list [file exists test.db-journal] [file exists test.db-wal]
  } {1 0}
}

# Test that nothing goes wrong if a connection is prevented from changing
# from WAL to rollback mode because a second connection has the database
# open. Or from rollback to WAL.
#
do_test walmode-4.6 {
  sqlite3 db2 test.db

Changes to test/zerodamage.test.

70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97







-
+












-
+







                    WHERE value BETWEEN 1 AND 400;
  }
  set ::max_journal_size 0
  db eval {
    UPDATE t1 SET y=randomblob(50) WHERE x=123;
  }
  concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]
} {0 1 2576}
} [list 0 1 [expr ([atomic_batch_write test.db]==0)*2576]]

# Repeat the previous step with zero-damage turned off.  This time the
# maximum rollback journal size should be much larger.
#
do_test zerodamage-2.1 {
  set ::max_journal_size 0
  db close
  sqlite3 db file:test.db?psow=FALSE -uri 1
  db eval {
    UPDATE t1 SET y=randomblob(50) WHERE x=124;
  }
  concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]
} {0 0 24704}
} [list 0 0 [expr ([atomic_batch_write test.db]==0)*24704]]

if {[wal_is_capable]} {
  # Run a WAL-mode transaction with POWERSAFE_OVERWRITE on to verify that the
  # WAL file does not get too big.
  #
  do_test zerodamage-3.0 {
    db eval {