AryaWu/sqlite
0
1# 2022 January 52#3# The author disclaims copyright to this source code. In place of4# 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.tcl15source $testdir/malloc_common.tcl16 17set ::testprefix returningfault18 19 20do_execsql_test 1.0 {21 CREATE TABLE t1 (b);22} {}23faultsim_save_and_close24 25do_faultsim_test 1 -faults oom-t* -prep {26 faultsim_restore_and_reopen27} -body {28 execsql { 29 INSERT INTO t1(b) VALUES(65) RETURNING (30 SELECT * FROM sqlite_temp_schema31 ) AS aaa;32 }33} -test {34 faultsim_test_result {1 {sub-select returns 5 columns - expected 1}}35}36 37ifcapable vtab {38 reset_db39 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 12360 }61 62 }63 64 return {}65 }66 67 faultsim_save_and_close68 69 do_faultsim_test 2 -faults oom* -prep {70 faultsim_restore_and_reopen71 register_tcl_module db eponymous_cmd72 db eval { SELECT * FROM t1 }73 sqlite3 db2 test.db74 db2 eval { CREATE TABLE t2(y) }75 db2 close76 } -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_test86 