SQLite

Check-in [6441f2dc9e]
Login

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

Overview
Comment:Add a test case to verify that "PRAGMA data_version" works as expected when an OTA client writes to the database.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6441f2dc9e7f53de64bc15b1d766c885b2635112
User & Date: dan 2015-07-07 19:07:30.099
Context
2015-07-07
19:35
Merge the Fts5MultiSegIter and Fts5IndexIter objects. (check-in: 6ace73541a user: dan tags: trunk)
19:07
Add a test case to verify that "PRAGMA data_version" works as expected when an OTA client writes to the database. (check-in: 6441f2dc9e user: dan tags: trunk)
08:29
Further optimizations for fts5 b-tree seeks. (check-in: f37899686c user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/ota/ota12.test.
162
163
164
165
166
167
168































































169
170
171
172

  do_test 2.$tn.11 {
    sqlite3ota ota test.db ota.db
    while {[ota step]=="SQLITE_OK"} {}
    ota close
  } {SQLITE_DONE}
































































}

finish_test








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




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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235

  do_test 2.$tn.11 {
    sqlite3ota ota test.db ota.db
    while {[ota step]=="SQLITE_OK"} {}
    ota close
  } {SQLITE_DONE}

}

#-------------------------------------------------------------------------
# Test that "PRAGMA data_version" works when an OTA client writes the
# database.
#
do_multiclient_test tn {

  # Initialize a target (test.db) and ota (ota.db) database.
  #
  forcedelete ota.db
  sql1 $setup_sql

  # Check the initial database contains table "xx" with a single row.
  # Also save the current values of "PRAGMA data-version" for [db1] 
  # and [db2].
  #
  do_test 2.$tn.1 {
    list [sql1 { SELECT count(*) FROM xx }] [sql2 { SELECT count(*) FROM xx }]
  } {1 1}
  set V1 [sql1 {PRAGMA data_version}] 
  set V2 [sql2 {PRAGMA data_version}]

  # Check the values of data-version have not magically changed.
  #
  do_test 2.$tn.2 {
    list [sql1 {PRAGMA data_version}] [sql2 {PRAGMA data_version}]
  } [list $V1 $V2]

  # Start stepping the OTA. From the point of view of [db1] and [db2], the 
  # data-version values remain unchanged until the database contents are
  # modified. At which point the values are incremented.
  #
  sqlite3ota ota test.db ota.db
  set x 0
  while {[db one {SELECT count(*) FROM xx}]==1} {
    do_test 2.$tn.3.[incr x] {
      list [sql1 {PRAGMA data_version}] [sql2 {PRAGMA data_version}]
    } [list $V1 $V2]
    ota step
  }
  do_test 2.$tn.5.1 { expr {$V1 < [sql1 {PRAGMA data_version}]} } 1
  do_test 2.$tn.5.2 { expr {$V2 < [sql2 {PRAGMA data_version}]} } 1

  # Check the db contents is as expected.
  #
  do_test 2.$tn.4 {
    list [sql1 {SELECT count(*) FROM xx}] [sql2 {SELECT count(*) FROM xx}]
  } {3 3}

  set V1 [sql1 {PRAGMA data_version}] 
  set V2 [sql2 {PRAGMA data_version}]

  # Finish applying the OTA (i.e. do the incremental checkpoint). Check that
  # this does not cause the data-version values to change.
  #
  while {[ota step]=="SQLITE_OK"} { }
  ota close

  do_test 2.$tn.6 {
    list [sql1 {PRAGMA data_version}] [sql2 {PRAGMA data_version}]
  } [list $V1 $V2]

}

finish_test