SQLite

Check-in [db314213c0]
Login

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

Overview
Comment:Test some extra error conditions in sqlite3_recover_snapshot().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | serializable-snapshot
Files: files | file ages | folders
SHA1: db314213c08f27dd0ff5ede3c6a8eda36560809a
User & Date: dan 2016-11-19 17:30:57.131
Context
2016-11-19
18:31
Remove the requirement to open the wal file before sqlite3_snapshot_recover() is called. Also add some comments to new functions. (check-in: 28393c413c user: dan tags: serializable-snapshot)
17:30
Test some extra error conditions in sqlite3_recover_snapshot(). (check-in: db314213c0 user: dan tags: serializable-snapshot)
17:20
Add another fault-injection test for sqlite3_snapshot_recover(). (check-in: 7e04040613 user: dan tags: serializable-snapshot)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/snapshot2.test.
149
150
151
152
153
154
155
156
157
158
159









































160
161
162
163
} {wal}
do_test 3.1 {
  sqlite3 db2 test.db
  execsql { INSERT INTO t1 VALUES('e', 'f') } db2
  db2 close
  sqlite3_snapshot_recover db main
} {}
breakpoint
do_execsql_test 3.2 {
  SELECT * FROM t1;
} {a b c d e f}










































finish_test









<



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




149
150
151
152
153
154
155

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
} {wal}
do_test 3.1 {
  sqlite3 db2 test.db
  execsql { INSERT INTO t1 VALUES('e', 'f') } db2
  db2 close
  sqlite3_snapshot_recover db main
} {}

do_execsql_test 3.2 {
  SELECT * FROM t1;
} {a b c d e f}

#-------------------------------------------------------------------------
# Check that sqlite3_snapshot_recover() returns an error if it is called
# with an open read-transaction. Or on a database that does not exist. Or
# on the temp database. Or on a db that is not in wal mode.
#
do_test 4.1 {
  sqlite3_snapshot_recover db main
} {}
do_test 4.2 {
  execsql {
    BEGIN;
      SELECT * FROM sqlite_master;
  }
  list [catch { sqlite3_snapshot_recover db main } msg] $msg
} {1 SQLITE_ERROR}
do_test 4.3 {
  execsql COMMIT
  sqlite3_snapshot_recover db main
} {}
do_test 4.4 {
  list [catch { sqlite3_snapshot_recover db aux } msg] $msg
} {1 SQLITE_ERROR}
do_test 4.5 {
  forcedelete test.db2
  execsql {
    ATTACH 'test.db2' AS aux;
    PRAGMA aux.journal_mode = wal;
    CREATE TABLE aux.t2(x, y);
  }
  list [catch { sqlite3_snapshot_recover db aux } msg] $msg
} {0 {}}
do_test 4.6 {
  list [catch { sqlite3_snapshot_recover db temp } msg] $msg
} {1 SQLITE_ERROR}
do_test 4.7 {
  execsql {
    PRAGMA aux.journal_mode = delete;
  }
  list [catch { sqlite3_snapshot_recover db aux } msg] $msg
} {1 SQLITE_ERROR}

finish_test