1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Improve the error messages returned by sqlite3session_diff().

FossilOrigin-Name: a3217cdb75fd305705856f6504f8816c2b6b0a10907725cb74d025a5c4e369b8
This commit is contained in:
dan
2025-04-10 16:48:04 +00:00
parent 08122e96fe
commit da00cc101c
5 changed files with 85 additions and 21 deletions

View File

@ -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