Skip to content

Commit 0e8cdf4

Browse files
committed
test for rekey after a large delete
1 parent 1a17b57 commit 0e8cdf4

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

test/crypto.test

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -282,32 +282,39 @@ do_test rekey-delete-and-query-1 {
282282
BEGIN;
283283
}
284284

285-
for {set i 1} {$i<10000} {incr i} {
286-
set r [expr {int(rand()*500000)}]
287-
execsql "INSERT INTO t1 VALUES($i,'value $r');"
285+
for {set i 1} {$i<1000} {incr i} {
286+
set r [expr {int(rand()*32767)}]
287+
set r1 [expr {int(rand()*32767)}]
288+
execsql "INSERT INTO t1 VALUES($r,$r1);"
288289
}
290+
set r [expr {int(rand()*32767)}]
291+
set r1 [expr {int(rand()*32767)}]
292+
execsql "UPDATE t1 SET b = $r WHERE a < $r1;"
293+
294+
set r [expr {int(rand()*32767)}]
295+
296+
execsql "DELETE FROM t1 WHERE a < $r;"
289297

290298
execsql {
291299
COMMIT;
292-
DELETE FROM t1 WHERE a > 5000;
293-
BEGIN;
294-
}
295-
296-
for {set i 10000} {$i<12500} {incr i} {
297-
set r [expr {int(rand()*500000)}]
298-
execsql "INSERT INTO t1 VALUES($i,'value $r');"
300+
SELECT (count(*) > 0) FROM t1;
299301
}
302+
} {1}
300303

304+
db close
305+
file copy -force test.db test-rekey.db
306+
307+
do_test rekey-delete-and-query-1 {
308+
sqlite_orig db test.db
301309
execsql {
310+
PRAGMA key = 'test123';
302311
PRAGMA rekey = 'test321';
303-
SELECT count(*) FROM t1;
312+
SELECT count(*) > 1 FROM t1;
304313
}
305-
} {7500}
306-
314+
} {}
307315
db close
308316
file delete -force test.db
309317

310-
311318
# attach an encrypted database
312319
# where both database have the same
313320
# key

0 commit comments

Comments
 (0)