interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / returningfault.test

85 lines · 1766 bytes Raw Blame History
1# 2022 January 5
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
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15source $testdir/malloc_common.tcl
16
17set ::testprefix returningfault
18
19
20do_execsql_test 1.0 {
21 CREATE TABLE t1 (b);
22} {}
23faultsim_save_and_close
24
25do_faultsim_test 1 -faults oom-t* -prep {
26 faultsim_restore_and_reopen
27} -body {
28 execsql {
29 INSERT INTO t1(b) VALUES(65) RETURNING (
30 SELECT * FROM sqlite_temp_schema
31 ) AS aaa;
32 }
33} -test {
34 faultsim_test_result {1 {sub-select returns 5 columns - expected 1}}
35}
36
37ifcapable vtab {
38 reset_db
39 do_execsql_test 2.0 {
40 CREATE TABLE t1(x);
41 }
42
43 proc eponymous_cmd {method args} {
44 switch -- $method {
45 xConnect {
46 db eval { SELECT * FROM sqlite_schema }
47 return "CREATE TABLE t1 (a, b)"
48 }
49
50 xBestIndex {
51 return "idxnum 555"
52 }
53
54 xFilter {
55 return [list sql {SELECT 123, 'A', 'B'}]
56 }
57
58 xUpdate {
59 return 123
60 }
61
62 }
63
64 return {}
65 }
66
67 faultsim_save_and_close
68
69 do_faultsim_test 2 -faults oom* -prep {
70 faultsim_restore_and_reopen
71 register_tcl_module db eponymous_cmd
72 db eval { SELECT * FROM t1 }
73 sqlite3 db2 test.db
74 db2 eval { CREATE TABLE t2(y) }
75 db2 close
76 } -body {
77 db eval {
78 INSERT INTO tcl VALUES('hello', 'world') RETURNING *
79 }
80 } -test {
81 faultsim_test_result {0 {hello world}} {1 {vtable constructor failed: tcl}}
82 }
83}
84
85finish_test