Fix a problem causing the recovery extension to use excessive memory and CPU time...
[sqlite.git] / test / e_blobbytes.test
blobc24318c565aceed3ff4efc60fe1089372cc45927
1 # 2014 October 30
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix e_blobbytes
17 ifcapable !incrblob {
18   finish_test
19   return
22 do_execsql_test 1.0 {
23   CREATE TABLE q1(r INTEGER PRIMARY KEY, s TEXT);
24   WITH d(a, b) AS (
25     SELECT 0, '' 
26       UNION ALL
27     SELECT a+1, b||'.' FROM d WHERE a<10000
28   )
29   INSERT INTO q1 SELECT * FROM d;
33 # EVIDENCE-OF: R-07796-55423 Returns the size in bytes of the BLOB
34 # accessible via the successfully opened BLOB handle in its only
35 # argument.
37 proc check_blob_size {tn rowid bytes} {
38   uplevel [list do_test $tn [subst -nocommands {
39     sqlite3_blob_open db main q1 s $rowid 0 B
40     set res [sqlite3_blob_bytes [set B]]
41     sqlite3_blob_close [set B]
42     set res
43   }] $bytes]
45 check_blob_size 1.1 43 43
46 check_blob_size 1.2 391 391
47 check_blob_size 1.3 6349 6349
48 check_blob_size 1.4 2621 2621
49 check_blob_size 1.5 7771 7771
50 check_blob_size 1.6 7949 7949
51 check_blob_size 1.7 4374 4374
52 check_blob_size 1.8 2578 2578
53 check_blob_size 1.9 7004 7004
54 check_blob_size 1.10 2180 2180
55 check_blob_size 1.11 3796 3796
56 check_blob_size 1.12 7101 7101
57 check_blob_size 1.13 7449 7449
58 check_blob_size 1.14 7224 7224
59 check_blob_size 1.15 3038 3038
60 check_blob_size 1.16 1083 1083
61 check_blob_size 1.17 5157 5157
62 check_blob_size 1.18 6686 6686
63 check_blob_size 1.19 6592 6592
64 check_blob_size 1.20 0 0
67 # EVIDENCE-OF: R-53088-19343 The incremental blob I/O routines can only
68 # read or overwriting existing blob content; they cannot change the size
69 # of a blob.
71 #   Also demonstrated in other e_blobXXX.test files.
73 do_test 2.1 {
74   sqlite3_blob_open db main q1 s 86 1 B
75   list [catch { sqlite3_blob_write $B 86 "1" 1 } msg] $msg
76 } {1 SQLITE_ERROR}
77 sqlite3_blob_close $B
79 finish_test