OLD | NEW |
1 # 2007 May 1 | 1 # 2007 May 1 |
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 #*********************************************************************** |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 db close | 201 db close |
202 sqlite3 db test.db | 202 sqlite3 db test.db |
203 | 203 |
204 execsql { SELECT i FROM blobs } | 204 execsql { SELECT i FROM blobs } |
205 } {45} | 205 } {45} |
206 | 206 |
207 do_test incrblob-2.$AutoVacuumMode.9 { | 207 do_test incrblob-2.$AutoVacuumMode.9 { |
208 nRead db | 208 nRead db |
209 } [expr $AutoVacuumMode ? 4 : 30] | 209 } [expr $AutoVacuumMode ? 4 : 30] |
210 } | 210 } |
211 sqlite3_soft_heap_limit $soft_limit | 211 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) |
212 | 212 |
213 #------------------------------------------------------------------------ | 213 #------------------------------------------------------------------------ |
214 # incrblob-3.*: | 214 # incrblob-3.*: |
215 # | 215 # |
216 # Test the outcome of trying to write to a read-only blob handle. | 216 # Test the outcome of trying to write to a read-only blob handle. |
217 # | 217 # |
218 do_test incrblob-3.1 { | 218 do_test incrblob-3.1 { |
219 set ::blob [db incrblob -readonly blobs v 1] | 219 set ::blob [db incrblob -readonly blobs v 1] |
220 seek $::blob -40 end | 220 seek $::blob -40 end |
221 read $::blob 20 | 221 read $::blob 20 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } msg ] | 302 } msg ] |
303 list $rc $msg | 303 list $rc $msg |
304 } {1 {cannot open value of type real}} | 304 } {1 {cannot open value of type real}} |
305 do_test incrblob-4.7 { | 305 do_test incrblob-4.7 { |
306 set rc [catch { | 306 set rc [catch { |
307 set ::blob [db incrblob blobs i 2] | 307 set ::blob [db incrblob blobs i 2] |
308 } msg ] | 308 } msg ] |
309 list $rc $msg | 309 list $rc $msg |
310 } {1 {cannot open value of type null}} | 310 } {1 {cannot open value of type null}} |
311 | 311 |
312 do_test incrblob-4.8 { | 312 do_test incrblob-4.8.1 { |
313 execsql { | 313 execsql { |
314 INSERT INTO blobs(k, v, i) VALUES(X'010203040506070809', 'hello', 'world'); | 314 INSERT INTO blobs(k, v, i) VALUES(X'010203040506070809', 'hello', 'world'); |
315 } | 315 } |
316 set rc [catch { | 316 set rc [catch { |
317 set ::blob [db incrblob blobs k 3] | 317 set ::blob [db incrblob blobs k 3] |
318 } msg ] | 318 } msg ] |
319 list $rc $msg | 319 list $rc $msg |
320 } {1 {cannot open indexed column for writing}} | 320 } {1 {cannot open indexed column for writing}} |
| 321 do_test incrblob-4.8.2 { |
| 322 execsql { |
| 323 CREATE TABLE t3(a INTEGER PRIMARY KEY, b); |
| 324 INSERT INTO t3 VALUES(1, 2); |
| 325 } |
| 326 set rc [catch { |
| 327 set ::blob [db incrblob -readonly t3 a 1] |
| 328 } msg ] |
| 329 list $rc $msg |
| 330 } {1 {cannot open value of type null}} |
| 331 do_test incrblob-4.8.3 { |
| 332 set rc [catch { |
| 333 set ::blob [db incrblob -readonly t3 rowid 1] |
| 334 } msg ] |
| 335 list $rc $msg |
| 336 } {1 {no such column: "rowid"}} |
321 | 337 |
322 do_test incrblob-4.9.1 { | 338 do_test incrblob-4.9.1 { |
323 set rc [catch { | 339 set rc [catch { |
324 set ::blob [db incrblob -readonly blobs k 3] | 340 set ::blob [db incrblob -readonly blobs k 3] |
325 } msg] | 341 } msg] |
326 } {0} | 342 } {0} |
327 do_test incrblob-4.9.2 { | 343 do_test incrblob-4.9.2 { |
328 binary scan [read $::blob] c* c | 344 binary scan [read $::blob] c* c |
329 close $::blob | 345 close $::blob |
330 set c | 346 set c |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 # incrblob-6.*: | 413 # incrblob-6.*: |
398 # | 414 # |
399 # Test that opening a blob for write-access is impossible if | 415 # Test that opening a blob for write-access is impossible if |
400 # another connection has the database RESERVED lock. | 416 # another connection has the database RESERVED lock. |
401 # | 417 # |
402 # Then test that blob writes that take place inside of a | 418 # Then test that blob writes that take place inside of a |
403 # transaction are not visible to external connections until | 419 # transaction are not visible to external connections until |
404 # after the transaction is commited and the blob channel | 420 # after the transaction is commited and the blob channel |
405 # closed. | 421 # closed. |
406 # | 422 # |
| 423 # This test does not work with the "memsubsys1" configuration. |
| 424 # Permutation memsubsys1 configures a very small static allocation |
| 425 # for use as page-cache memory. This causes SQLite to upgrade |
| 426 # to an exclusive lock when writing earlier than usual, which |
| 427 # makes some of these tests fail. |
| 428 # |
407 sqlite3_soft_heap_limit 0 | 429 sqlite3_soft_heap_limit 0 |
408 do_test incrblob-6.1 { | 430 if {[permutation] != "memsubsys1"} { |
409 sqlite3 db2 test.db | 431 do_test incrblob-6.1 { |
410 execsql { | 432 sqlite3 db2 test.db |
411 BEGIN; | 433 execsql { |
412 INSERT INTO blobs(k, v, i) VALUES('a', 'different', 'connection'); | 434 BEGIN; |
413 } db2 | 435 INSERT INTO blobs(k, v, i) VALUES('a', 'different', 'connection'); |
414 } {} | 436 } db2 |
415 do_test incrblob-6.2 { | 437 } {} |
416 execsql { | 438 do_test incrblob-6.2 { |
417 SELECT rowid FROM blobs | 439 execsql { |
418 } | 440 SELECT rowid FROM blobs |
419 } {1 2 3} | 441 } |
420 do_test incrblob-6.3 { | 442 } {1 2 3} |
421 set rc [catch { | 443 do_test incrblob-6.3 { |
422 db incrblob blobs v 1 | 444 set rc [catch { |
423 } msg] | 445 db incrblob blobs v 1 |
424 list $rc $msg | 446 } msg] |
425 } {1 {database is locked}} | 447 list $rc $msg |
426 do_test incrblob-6.4 { | 448 } {1 {database is locked}} |
427 set rc [catch { | 449 do_test incrblob-6.4 { |
428 db incrblob blobs v 3 | 450 set rc [catch { |
429 } msg] | 451 db incrblob blobs v 3 |
430 list $rc $msg | 452 } msg] |
431 } {1 {database is locked}} | 453 list $rc $msg |
432 do_test incrblob-6.5 { | 454 } {1 {database is locked}} |
433 set ::blob [db incrblob -readonly blobs v 3] | 455 do_test incrblob-6.5 { |
434 read $::blob | 456 set ::blob [db incrblob -readonly blobs v 3] |
435 } {hello} | 457 read $::blob |
436 do_test incrblob-6.6 { | 458 } {hello} |
437 close $::blob | 459 do_test incrblob-6.6 { |
438 } {} | 460 close $::blob |
439 | 461 } {} |
440 do_test incrblob-6.7 { | 462 |
441 set ::blob [db2 incrblob blobs i 4] | 463 do_test incrblob-6.7 { |
442 gets $::blob | 464 set ::blob [db2 incrblob blobs i 4] |
443 } {connection} | 465 gets $::blob |
444 do_test incrblob-6.8 { | 466 } {connection} |
445 tell $::blob | 467 do_test incrblob-6.8 { |
446 } {10} | 468 tell $::blob |
447 do_test incrblob-6.9 { | 469 } {10} |
448 seek $::blob 0 | 470 do_test incrblob-6.9 { |
449 puts -nonewline $::blob "invocation" | 471 seek $::blob 0 |
450 flush $::blob | 472 puts -nonewline $::blob "invocation" |
451 } {} | 473 flush $::blob |
452 | 474 } {} |
453 # At this point rollback should be illegal (because | 475 |
454 # there is an open blob channel). But commit is also illegal because | 476 # At this point rollback should be illegal (because |
455 # the open blob is read-write. | 477 # there is an open blob channel). But commit is also illegal because |
456 # | 478 # the open blob is read-write. |
457 do_test incrblob-6.10 { | 479 # |
458 catchsql { | 480 do_test incrblob-6.10 { |
459 ROLLBACK; | 481 catchsql { |
460 } db2 | 482 ROLLBACK; |
461 } {1 {cannot rollback transaction - SQL statements in progress}} | 483 } db2 |
462 do_test incrblob-6.11 { | 484 } {1 {cannot rollback transaction - SQL statements in progress}} |
463 catchsql { | 485 do_test incrblob-6.11 { |
464 COMMIT; | 486 catchsql { |
465 } db2 | 487 COMMIT; |
466 } {1 {cannot commit transaction - SQL statements in progress}} | 488 } db2 |
467 | 489 } {1 {cannot commit transaction - SQL statements in progress}} |
468 do_test incrblob-6.12 { | 490 |
469 execsql { | 491 do_test incrblob-6.12 { |
470 SELECT * FROM blobs WHERE rowid = 4; | 492 execsql { |
471 } | 493 SELECT * FROM blobs WHERE rowid = 4; |
472 } {} | 494 } |
473 do_test incrblob-6.13 { | 495 } {} |
474 close $::blob | 496 do_test incrblob-6.13 { |
475 } {} | 497 close $::blob |
476 do_test incrblob-6.14 { | 498 } {} |
477 catchsql { | 499 do_test incrblob-6.14 { |
478 COMMIT; | 500 catchsql { |
479 } db2 | 501 COMMIT; |
480 } {0 {}} | 502 } db2 |
481 do_test incrblob-6.15 { | 503 } {0 {}} |
482 execsql { | 504 do_test incrblob-6.15 { |
483 SELECT * FROM blobs WHERE rowid = 4; | 505 execsql { |
484 } | 506 SELECT * FROM blobs WHERE rowid = 4; |
485 } {a different invocation} | 507 } |
486 db2 close | 508 } {a different invocation} |
487 sqlite3_soft_heap_limit $soft_limit | 509 db2 close |
| 510 } |
| 511 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) |
488 | 512 |
489 #----------------------------------------------------------------------- | 513 #----------------------------------------------------------------------- |
490 # The following tests verify the behaviour of the incremental IO | 514 # The following tests verify the behaviour of the incremental IO |
491 # APIs in the following cases: | 515 # APIs in the following cases: |
492 # | 516 # |
493 # 7.1 A row that containing an open blob is modified. | 517 # 7.1 A row that containing an open blob is modified. |
494 # | 518 # |
495 # 7.2 A CREATE TABLE requires that an overflow page that is part | 519 # 7.2 A CREATE TABLE requires that an overflow page that is part |
496 # of an open blob is moved. | 520 # of an open blob is moved. |
497 # | 521 # |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 execsql {SELECT b FROM t1 WHERE a = 314159} | 670 execsql {SELECT b FROM t1 WHERE a = 314159} |
647 } {sqlite} | 671 } {sqlite} |
648 do_test incrblob-8.6 { | 672 do_test incrblob-8.6 { |
649 set rc [catch {sqlite3_blob_write $::b 0 etilqs 6} msg] | 673 set rc [catch {sqlite3_blob_write $::b 0 etilqs 6} msg] |
650 lappend rc $msg | 674 lappend rc $msg |
651 } {0 {}} | 675 } {0 {}} |
652 do_test incrblob-8.7 { | 676 do_test incrblob-8.7 { |
653 execsql {SELECT b FROM t1 WHERE a = 314159} | 677 execsql {SELECT b FROM t1 WHERE a = 314159} |
654 } {etilqs} | 678 } {etilqs} |
655 | 679 |
| 680 # The following test case exposes an instance in the blob code where |
| 681 # an error message was set using a call similar to sqlite3_mprintf(zErr), |
| 682 # where zErr is an arbitrary string. This is no good if the string contains |
| 683 # characters that can be mistaken for printf() formatting directives. |
| 684 # |
| 685 do_test incrblob-9.1 { |
| 686 list [catch { db incrblob t1 "A tricky column name %s%s" 1 } msg] $msg |
| 687 } {1 {no such column: "A tricky column name %s%s"}} |
| 688 |
656 | 689 |
657 finish_test | 690 finish_test |
OLD | NEW |