sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | # 2006 June 10 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 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. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | # $Id: vtab_err.test,v 1.8 2007/09/03 16:12:10 drh Exp $ |
| 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
| 16 | |
| 17 | ifcapable !vtab { |
| 18 | finish_test |
| 19 | return |
| 20 | } |
| 21 | |
| 22 | |
| 23 | unset -nocomplain echo_module_begin_fail |
| 24 | do_ioerr_test vtab_err-1 -tclprep { |
| 25 | register_echo_module [sqlite3_connection_pointer db] |
| 26 | } -sqlbody { |
| 27 | BEGIN; |
| 28 | CREATE TABLE r(a PRIMARY KEY, b, c); |
| 29 | CREATE VIRTUAL TABLE e USING echo(r); |
| 30 | INSERT INTO e VALUES(1, 2, 3); |
| 31 | INSERT INTO e VALUES('a', 'b', 'c'); |
| 32 | UPDATE e SET c = 10; |
| 33 | DELETE FROM e WHERE a = 'a'; |
| 34 | COMMIT; |
| 35 | BEGIN; |
| 36 | CREATE TABLE r2(a, b, c); |
| 37 | INSERT INTO r2 SELECT * FROM e; |
| 38 | INSERT INTO e SELECT a||'x', b, c FROM r2; |
| 39 | COMMIT; |
| 40 | } |
| 41 | |
| 42 | source $testdir/malloc_common.tcl |
| 43 | |
| 44 | |
| 45 | do_malloc_test vtab_err-2 -tclprep { |
| 46 | register_echo_module [sqlite3_connection_pointer db] |
| 47 | } -sqlbody { |
| 48 | BEGIN; |
| 49 | CREATE TABLE r(a PRIMARY KEY, b, c); |
| 50 | CREATE VIRTUAL TABLE e USING echo(r); |
| 51 | INSERT INTO e VALUES(1, 2, 3); |
| 52 | INSERT INTO e VALUES('a', 'b', 'c'); |
| 53 | UPDATE e SET c = 10; |
| 54 | DELETE FROM e WHERE a = 'a'; |
| 55 | COMMIT; |
| 56 | BEGIN; |
| 57 | CREATE TABLE r2(a, b, c); |
| 58 | INSERT INTO r2 SELECT * FROM e; |
| 59 | INSERT INTO e SELECT a||'x', b, c FROM r2; |
| 60 | COMMIT; |
| 61 | } |
| 62 | |
| 63 | sqlite3_memdebug_fail -1 |
| 64 | |
| 65 | reset_db |
| 66 | register_echo_module [sqlite3_connection_pointer db] |
| 67 | do_execsql_test vtab_err-3.0 { |
| 68 | CREATE TABLE r(a PRIMARY KEY, b, c); |
| 69 | CREATE VIRTUAL TABLE e USING echo(r); |
| 70 | } |
| 71 | faultsim_save_and_close |
| 72 | |
| 73 | do_faultsim_test vtab_err-3 -faults oom-t* -prep { |
| 74 | faultsim_restore_and_reopen |
| 75 | register_echo_module [sqlite3_connection_pointer db] |
| 76 | } -body { |
| 77 | execsql { |
| 78 | BEGIN; |
| 79 | CREATE TABLE xyz(x); |
| 80 | SELECT a FROM e; |
| 81 | COMMIT; |
| 82 | } |
| 83 | } -test { |
| 84 | faultsim_test_result {0 {}} |
| 85 | } |
| 86 | |
| 87 | finish_test |