Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/sqlite/src/test/zeroblob.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/wordcount.c ('k') | third_party/sqlite/src/tool/GetFile.cs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2007 May 02 1 # 2007 May 02
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing of the zero-filled blob functionality 12 # focus of this file is testing of the zero-filled blob functionality
13 # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(), 13 # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
14 # and the built-in zeroblob() SQL function. 14 # and the built-in zeroblob() SQL function.
15 # 15 #
16 # $Id: zeroblob.test,v 1.14 2009/07/14 02:33:02 drh Exp $ 16 # $Id: zeroblob.test,v 1.14 2009/07/14 02:33:02 drh Exp $
17 17
18 set testdir [file dirname $argv0] 18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl 19 source $testdir/tester.tcl
20 set testprefix zeroblob
20 21
21 ifcapable !incrblob { 22 ifcapable !incrblob {
22 finish_test 23 finish_test
23 return 24 return
24 } 25 }
25 26
27 test_set_config_pagecache 0 0
28
26 # When zeroblob() is used for the last field of a column, then the 29 # When zeroblob() is used for the last field of a column, then the
27 # content of the zeroblob is never instantiated on the VDBE stack. 30 # content of the zeroblob is never instantiated on the VDBE stack.
28 # But it does get inserted into the database correctly. 31 # But it does get inserted into the database correctly.
29 # 32 #
30 db eval {PRAGMA cache_size=10} 33 db eval {PRAGMA cache_size=10}
31 sqlite3_memory_highwater 1 34 sqlite3_memory_highwater 1
32 unset -nocomplain memused 35 unset -nocomplain memused
33 set memused [sqlite3_memory_used] 36 set memused [sqlite3_memory_used]
34 do_test zeroblob-1.1 { 37 do_test zeroblob-1.1 {
35 execsql { 38 execsql {
36 CREATE TABLE t1(a,b,c,d); 39 CREATE TABLE t1(a,b,c,d);
37 } 40 }
38 set ::sqlite3_max_blobsize 0 41 set ::sqlite3_max_blobsize 0
39 execsql { 42 execsql {
40 INSERT INTO t1 VALUES(2,3,4,zeroblob(1000000)); 43 INSERT INTO t1 VALUES(2,3,4,zeroblob(1000000));
41 } 44 }
42 set ::sqlite3_max_blobsize 45 set ::sqlite3_max_blobsize
43 } {10} 46 } {10}
47
44 do_test zeroblob-1.1.1 { 48 do_test zeroblob-1.1.1 {
45 expr {[sqlite3_memory_highwater]<$::memused+25000} 49 expr {[sqlite3_memory_highwater]<$::memused+35000}
46 } {1} 50 } {1}
47 do_test zeroblob-1.2 { 51 do_test zeroblob-1.2 {
48 execsql { 52 execsql {
49 SELECT length(d) FROM t1 53 SELECT length(d) FROM t1
50 } 54 }
51 } {1000000} 55 } {1000000}
52 56
53 # If a non-NULL column follows the zeroblob, then the content of 57 # If a non-NULL column follows the zeroblob, then the content of
54 # the zeroblob must be instantiated. 58 # the zeroblob must be instantiated.
55 # 59 #
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 do_test zeroblob-9.6 { 252 do_test zeroblob-9.6 {
249 db eval {SELECT x'0000' IN (zeroblob(2))} 253 db eval {SELECT x'0000' IN (zeroblob(2))}
250 } {1} 254 } {1}
251 do_test zeroblob-9.7 { 255 do_test zeroblob-9.7 {
252 db eval {SELECT zeroblob(2) IN (zeroblob(3))} 256 db eval {SELECT zeroblob(2) IN (zeroblob(3))}
253 } {0} 257 } {0}
254 do_test zeroblob-9.8 { 258 do_test zeroblob-9.8 {
255 db eval {SELECT zeroblob(2) IN (zeroblob(2))} 259 db eval {SELECT zeroblob(2) IN (zeroblob(2))}
256 } {1} 260 } {1}
257 261
262 # Oversized zeroblob records
263 #
264 do_test zeroblob-10.1 {
265 db eval {
266 CREATE TABLE t10(a,b,c);
267 }
268 catchsql {INSERT INTO t10 VALUES(zeroblob(1e9),zeroblob(1e9),zeroblob(1e9))}
269 } {1 {string or blob too big}}
258 270
271 #-------------------------------------------------------------------------
272 # Test the zeroblob() function on its own with negative or oversized
273 # arguments.
274 #
275 do_execsql_test 11.0 {
276 SELECT length(zeroblob(-1444444444444444));
277 } {0}
278 do_catchsql_test 11.1 {
279 SELECT zeroblob(5000 * 1024 * 1024);
280 } {1 {string or blob too big}}
281 do_catchsql_test 11.2 {
282 SELECT quote(zeroblob(5000 * 1024 * 1024));
283 } {1 {string or blob too big}}
284 do_catchsql_test 11.3 {
285 SELECT quote(zeroblob(-1444444444444444));
286 } {0 X''}
287 do_catchsql_test 11.4 {
288 SELECT quote(test_zeroblob(-1));
289 } {0 X''}
290
291 #-------------------------------------------------------------------------
292 # Test the sqlite3_bind_zeroblob64() API.
293 #
294 proc bind_and_run {stmt nZero} {
295 sqlite3_bind_zeroblob64 $stmt 1 $nZero
296 sqlite3_step $stmt
297 set ret [sqlite3_column_int $stmt 0]
298 sqlite3_reset $stmt
299 set ret
300 }
301 set stmt [sqlite3_prepare db "SELECT length(?)" -1 dummy]
302
303 do_test 12.1 { bind_and_run $stmt 40 } 40
304 do_test 12.2 { bind_and_run $stmt 0 } 0
305 do_test 12.3 { bind_and_run $stmt 1000 } 1000
306
307 do_test 12.4 {
308 list [catch { bind_and_run $stmt [expr 5000 * 1024 * 1024] } msg] $msg
309 } {1 SQLITE_TOOBIG}
310 do_test 12.5 {
311 sqlite3_step $stmt
312 set ret [sqlite3_column_int $stmt 0]
313 sqlite3_reset $stmt
314 set ret
315 } {1000}
316
317 sqlite3_finalize $stmt
318
319 test_restore_config_pagecache
259 finish_test 320 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/wordcount.c ('k') | third_party/sqlite/src/tool/GetFile.cs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698