diff options
author | drh <drh@noemail.net> | 2003-08-05 13:13:38 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2003-08-05 13:13:38 +0000 |
commit | 37ed48ed2fd1918b43f8ffdbf96dce8fcf8fb64c (patch) | |
tree | e39cbda59e418f5feacd6bd2283098c4df1df242 /test | |
parent | 4305d10360ab7b6fba381b9e783e14503a513b58 (diff) | |
download | sqlite-37ed48ed2fd1918b43f8ffdbf96dce8fcf8fb64c.tar.gz sqlite-37ed48ed2fd1918b43f8ffdbf96dce8fcf8fb64c.zip |
Provide a more informative error message when a uniqueness constraint
fails. Ticket #419. (CVS 1068)
FossilOrigin-Name: 086aa1c9922b7bf399b3ee8b73ba7353d126b119
Diffstat (limited to 'test')
-rw-r--r-- | test/capi2.test | 6 | ||||
-rw-r--r-- | test/conflict.test | 28 | ||||
-rw-r--r-- | test/copy.test | 4 | ||||
-rw-r--r-- | test/memdb.test | 4 | ||||
-rw-r--r-- | test/misc1.test | 4 | ||||
-rw-r--r-- | test/trigger2.test | 12 | ||||
-rw-r--r-- | test/unique.test | 41 | ||||
-rw-r--r-- | test/update.test | 6 |
8 files changed, 68 insertions, 37 deletions
diff --git a/test/capi2.test b/test/capi2.test index d6866a45a..92073e0ac 100644 --- a/test/capi2.test +++ b/test/capi2.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # -# $Id: capi2.test,v 1.9 2003/07/09 00:28:15 drh Exp $ +# $Id: capi2.test,v 1.10 2003/08/05 13:13:38 drh Exp $ # set testdir [file dirname $argv0] @@ -178,7 +178,7 @@ do_test capi2-3.13 { do_test capi2-3.13b {db changes} {0} do_test capi2-3.14 { list [catch {sqlite_finalize $VM} msg] [set msg] -} {1 {(19) uniqueness constraint failed}} +} {1 {(19) column a is not unique}} do_test capi2-3.15 { set VM [sqlite_compile $DB {CREATE TABLE t2(a NOT NULL, b)} TAIL] set TAIL @@ -386,7 +386,7 @@ do_test capi2-6.27 { INSERT INTO t1 VALUES(2,4,5); SELECT * FROM t1; } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test capi2-6.28 { list [sqlite_step $VM1 N VALUE COLNAME] [set N] [set VALUE] [set COLNAME] } {SQLITE_ROW 1 13 {x counter}} diff --git a/test/conflict.test b/test/conflict.test index 95b042d84..925c161fa 100644 --- a/test/conflict.test +++ b/test/conflict.test @@ -13,7 +13,7 @@ # This file implements tests for the conflict resolution extension # to SQLite. # -# $Id: conflict.test,v 1.18 2003/06/15 23:42:25 drh Exp $ +# $Id: conflict.test,v 1.19 2003/08/05 13:13:39 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -363,7 +363,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} { 25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1 26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0 } { - if {$t0} {set t1 {uniqueness constraint failed}} + if {$t0} {set t1 {column a is not unique}} do_test conflict-6.$i { if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"} @@ -539,13 +539,13 @@ do_test conflict-9.5 { INSERT INTO t2 VALUES(3,1,3,3,3); SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test conflict-9.6 { catchsql { UPDATE t2 SET b=b+1 WHERE b=1; SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test conflict-9.7 { catchsql { BEGIN; @@ -553,7 +553,7 @@ do_test conflict-9.7 { INSERT INTO t2 VALUES(3,1,3,3,3); SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test conflict-9.8 { execsql {COMMIT} execsql {SELECT * FROM t3} @@ -565,7 +565,7 @@ do_test conflict-9.9 { UPDATE t2 SET b=b+1 WHERE b=1; SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test conflict-9.10 { execsql {COMMIT} execsql {SELECT * FROM t3} @@ -575,13 +575,13 @@ do_test conflict-9.11 { INSERT INTO t2 VALUES(3,3,3,1,3); SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column d is not unique}} do_test conflict-9.12 { catchsql { UPDATE t2 SET d=d+1 WHERE d=1; SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column d is not unique}} do_test conflict-9.13 { catchsql { BEGIN; @@ -589,7 +589,7 @@ do_test conflict-9.13 { INSERT INTO t2 VALUES(3,3,3,1,3); SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column d is not unique}} do_test conflict-9.14 { execsql {COMMIT} execsql {SELECT * FROM t3} @@ -601,7 +601,7 @@ do_test conflict-9.15 { UPDATE t2 SET d=d+1 WHERE d=1; SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column d is not unique}} do_test conflict-9.16 { execsql {COMMIT} execsql {SELECT * FROM t3} @@ -611,13 +611,13 @@ do_test conflict-9.17 { INSERT INTO t2 VALUES(3,3,3,3,1); SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column e is not unique}} do_test conflict-9.18 { catchsql { UPDATE t2 SET e=e+1 WHERE e=1; SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column e is not unique}} do_test conflict-9.19 { catchsql { BEGIN; @@ -625,7 +625,7 @@ do_test conflict-9.19 { INSERT INTO t2 VALUES(3,3,3,3,1); SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column e is not unique}} do_test conflict-9.20 { catch {execsql {COMMIT}} execsql {SELECT * FROM t3} @@ -637,7 +637,7 @@ do_test conflict-9.21 { UPDATE t2 SET e=e+1 WHERE e=1; SELECT * FROM t2; } -} {1 {uniqueness constraint failed}} +} {1 {column e is not unique}} do_test conflict-9.22 { catch {execsql {COMMIT}} execsql {SELECT * FROM t3} diff --git a/test/copy.test b/test/copy.test index d439b51b6..37301c9f3 100644 --- a/test/copy.test +++ b/test/copy.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the COPY statement. # -# $Id: copy.test,v 1.14 2003/06/02 22:50:27 drh Exp $ +# $Id: copy.test,v 1.15 2003/08/05 13:13:39 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -196,7 +196,7 @@ do_test copy-5.2 { COPY t1 FROM 'data6.txt' USING DELIMITERS '|'; SELECT * FROM t1; } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test copy-5.3 { set fd [open data6.txt w] puts $fd "33|22|44" diff --git a/test/memdb.test b/test/memdb.test index b03d0caaa..383b927ec 100644 --- a/test/memdb.test +++ b/test/memdb.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is in-memory database backend. # -# $Id: memdb.test,v 1.5 2003/06/15 23:42:25 drh Exp $ +# $Id: memdb.test,v 1.6 2003/08/05 13:13:39 drh Exp $ set testdir [file dirname $argv0] @@ -253,7 +253,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} { 25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1 26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0 } { - if {$t0} {set t1 {uniqueness constraint failed}} + if {$t0} {set t1 {column a is not unique}} do_test memdb-5.$i { if {$conf1!=""} {set conf1 "ON CONFLICT $conf1"} if {$conf2!=""} {set conf2 "ON CONFLICT $conf2"} diff --git a/test/misc1.test b/test/misc1.test index d2f1b7a7e..4ddea47b7 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -13,7 +13,7 @@ # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc1.test,v 1.22 2003/06/03 01:47:12 drh Exp $ +# $Id: misc1.test,v 1.23 2003/08/05 13:13:39 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -222,7 +222,7 @@ do_test misc1-7.4 { catchsql { INSERT INTO t5 VALUES(1,2,4); } -} {1 {uniqueness constraint failed}} +} {1 {columns a, b are not unique}} do_test misc1-7.5 { catchsql { INSERT INTO t5 VALUES(0,2,4); diff --git a/test/trigger2.test b/test/trigger2.test index b0bcfdc3d..eb3d4f63e 100644 --- a/test/trigger2.test +++ b/test/trigger2.test @@ -472,7 +472,7 @@ do_test trigger2-6.1b { catchsql { INSERT OR ABORT INTO tbl values (2, 2, 3); } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test trigger2-6.1c { execsql { SELECT * from tbl; @@ -482,7 +482,7 @@ do_test trigger2-6.1d { catchsql { INSERT OR FAIL INTO tbl values (2, 2, 3); } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test trigger2-6.1e { execsql { SELECT * from tbl; @@ -498,7 +498,7 @@ do_test trigger2-6.1g { catchsql { INSERT OR ROLLBACK INTO tbl values (3, 2, 3); } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test trigger2-6.1h { execsql { SELECT * from tbl; @@ -526,7 +526,7 @@ do_test trigger2-6.2b { catchsql { UPDATE OR ABORT tbl SET a = 4 WHERE a = 1; } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test trigger2-6.2c { execsql { SELECT * from tbl; @@ -536,7 +536,7 @@ do_test trigger2-6.2d { catchsql { UPDATE OR FAIL tbl SET a = 4 WHERE a = 1; } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test trigger2-6.2e { execsql { SELECT * from tbl; @@ -558,7 +558,7 @@ do_test trigger2-6.2g { catchsql { UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1; } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test trigger2-6.2h { execsql { SELECT * from tbl; diff --git a/test/unique.test b/test/unique.test index b483b2571..63d1c37b4 100644 --- a/test/unique.test +++ b/test/unique.test @@ -12,7 +12,7 @@ # focus of this file is testing the CREATE UNIQUE INDEX statement, # and primary keys, and the UNIQUE constraint on table columns # -# $Id: unique.test,v 1.6 2003/06/15 23:42:25 drh Exp $ +# $Id: unique.test,v 1.7 2003/08/05 13:13:39 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -47,7 +47,7 @@ do_test unique-1.3 { catchsql { INSERT INTO t1(a,b,c) VALUES(1,3,4) } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test unique-1.4 { execsql { SELECT * FROM t1 ORDER BY a; @@ -57,7 +57,7 @@ do_test unique-1.5 { catchsql { INSERT INTO t1(a,b,c) VALUES(3,2,4) } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test unique-1.6 { execsql { SELECT * FROM t1 ORDER BY a; @@ -98,7 +98,7 @@ do_test unique-2.3 { catchsql { INSERT INTO t2 VALUES(1,5); } -} {1 {uniqueness constraint failed}} +} {1 {column a is not unique}} do_test unique-2.4 { catchsql { SELECT * FROM t2 ORDER BY a @@ -162,7 +162,7 @@ do_test unique-3.4 { INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5); SELECT * FROM t3 ORDER BY a,b,c,d; } -} {1 {uniqueness constraint failed}} +} {1 {columns a, c, d are not unique}} integrity_check unique-3.5 # Make sure NULLs are distinct as far as the UNIQUE tests are @@ -198,4 +198,35 @@ do_test unique-4.5 { } {1 2 3 {} 2 {} {} 3 4 2 2 {}} integrity_check unique-4.6 +# Test the error message generation logic. In particular, make sure we +# do not overflow the static buffer used to generate the error message. +# +do_test unique-5.1 { + execsql { + CREATE TABLE t5( + first_column_with_long_name, + second_column_with_long_name, + third_column_with_long_name, + fourth_column_with_long_name, + fifth_column_with_long_name, + sixth_column_with_long_name, + UNIQUE( + first_column_with_long_name, + second_column_with_long_name, + third_column_with_long_name, + fourth_column_with_long_name, + fifth_column_with_long_name, + sixth_column_with_long_name + ) + ); + INSERT INTO t5 VALUES(1,2,3,4,5,6); + SELECT * FROM t5; + } +} {1 2 3 4 5 6} +do_test unique-5.2 { + catchsql { + INSERT INTO t5 VALUES(1,2,3,4,5,6); + } +} {1 {columns first_column_with_long_name, second_column_with_long_name, third_column_with_long_name, fourth_column_with_long_name, fifth_column_with_long_name, ... are not unique}} + finish_test diff --git a/test/update.test b/test/update.test index c59a64039..049370f9b 100644 --- a/test/update.test +++ b/test/update.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the UPDATE statement. # -# $Id: update.test,v 1.13 2003/06/15 23:42:25 drh Exp $ +# $Id: update.test,v 1.14 2003/08/05 13:13:39 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -457,7 +457,7 @@ do_test update-10.6 { UPDATE t1 SET b=2, e=12 WHERE f=7; SELECT * FROM t1; } -} {1 {uniqueness constraint failed}} +} {1 {column b is not unique}} do_test update-10.7 { catchsql { SELECT * FROM t1; @@ -474,7 +474,7 @@ do_test update-10.9 { UPDATE t1 SET c=3, d=4, e=14 WHERE f=7; SELECT * FROM t1; } -} {1 {uniqueness constraint failed}} +} {1 {columns c, d are not unique}} do_test update-10.10 { catchsql { SELECT * FROM t1; |