diff options
author | dan <Dan Kennedy> | 2025-04-10 16:48:04 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2025-04-10 16:48:04 +0000 |
commit | da00cc101c208caeddfef8b1739d390a2bc60f8a (patch) | |
tree | 9b75f83ea1c73818d7a90934220228829adc3192 /ext/session/sessionD.test | |
parent | 08122e96fea0acf66d33b9f5e9650f6ebb841431 (diff) | |
download | sqlite-da00cc101c208caeddfef8b1739d390a2bc60f8a.tar.gz sqlite-da00cc101c208caeddfef8b1739d390a2bc60f8a.zip |
Improve the error messages returned by sqlite3session_diff().
FossilOrigin-Name: a3217cdb75fd305705856f6504f8816c2b6b0a10907725cb74d025a5c4e369b8
Diffstat (limited to 'ext/session/sessionD.test')
-rw-r--r-- | ext/session/sessionD.test | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/ext/session/sessionD.test b/ext/session/sessionD.test index f60fbabc2..74bb101e3 100644 --- a/ext/session/sessionD.test +++ b/ext/session/sessionD.test @@ -202,7 +202,7 @@ do_test 4.3.1 { S attach t4 execsql { CREATE TABLE t4(i PRIMARY KEY, b) } list [catch { S diff ixua t4 } msg] $msg -} {1 {SQLITE_SCHEMA - table schemas do not match}} +} {1 {SQLITE_SCHEMA - no such table: ixua.t4}} S delete do_catchsql_test 4.3.2 { SELECT * FROM ixua.t4; @@ -214,7 +214,7 @@ do_test 4.4.1 { execsql { ANALYZE } execsql { DROP TABLE ixua.sqlite_stat1 } list [catch { S diff ixua sqlite_stat1 } msg] $msg -} {1 {SQLITE_SCHEMA - table schemas do not match}} +} {1 {SQLITE_SCHEMA - no such table: ixua.sqlite_stat1}} S delete do_catchsql_test 4.4.2 { SELECT * FROM ixua.sqlite_stat1; @@ -258,4 +258,42 @@ do_changeset_test 4.2 S { S delete +#------------------------------------------------------------------------- +# Test that sqlite3session_diff() really does return errors if +# +reset_db +forcedelete test.db2 +do_execsql_test 5.0 { + ATTACH 'test.db2' AS two; + CREATE TABLE main.t1(a INTEGER PRIMARY KEY, b); + CREATE TABLE main.t2(a INTEGER PRIMARY KEY, b); + CREATE TABLE two.t1(a, b INTEGER PRIMARY KEY); +} + +proc do_sessions_diff_error {tn db tbl err} { + sqlite3session S db main + set rc [catch {S diff $db $tbl} msg] + + set ::sdgot [list $rc $msg] + do_test $tn [list set sdgot] [list {*}$err] + + S delete +} + +# Test that it is an error if the named db is missing. +breakpoint +do_sessions_diff_error 5.1 nosuchdb t1 { + 1 {SQLITE_SCHEMA - no such table: nosuchdb.t1} +} + +# Test that it is an error if the named db is present, but named table is not. +do_sessions_diff_error 5.2 two t2 { + 1 {SQLITE_SCHEMA - no such table: two.t2} +} + +# Test that it is an error if the tables are present, but schemas do not match. +do_sessions_diff_error 5.3 two t1 { + 1 {SQLITE_SCHEMA - table schemas do not match} +} + finish_test |