diff options
author | drh <drh@noemail.net> | 2013-02-09 15:37:11 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-02-09 15:37:11 +0000 |
commit | 433dccfb52eb5c7a7c884560df5c4b9d97b52cb8 (patch) | |
tree | 7a7842cd8bd5d082faf675a8e2d01bff565b374f | |
parent | d91c1a1768d4970276bf883251218d0ed1036329 (diff) | |
download | sqlite-433dccfb52eb5c7a7c884560df5c4b9d97b52cb8.tar.gz sqlite-433dccfb52eb5c7a7c884560df5c4b9d97b52cb8.zip |
Rename SQLITE_CONSTRAINT_RAISE to SQLITE_CONSTRAINT_TRIGGER. Put the
extended constraint error codes in alphabetical order. Add many test cases
for the extended constraint error codes.
FossilOrigin-Name: 3f67437536591a1b0742a25b983707933aaa16d5
-rw-r--r-- | manifest | 41 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/expr.c | 2 | ||||
-rw-r--r-- | src/sqlite.h.in | 16 | ||||
-rw-r--r-- | src/test1.c | 2 | ||||
-rw-r--r-- | test/capi2.test | 14 | ||||
-rw-r--r-- | test/conflict.test | 4 | ||||
-rw-r--r-- | test/errmsg.test | 2 | ||||
-rw-r--r-- | test/fkey2.test | 7 | ||||
-rw-r--r-- | test/fkey4.test | 2 | ||||
-rw-r--r-- | test/hook.test | 1 | ||||
-rw-r--r-- | test/notnull.test | 27 | ||||
-rw-r--r-- | test/tester.tcl | 7 | ||||
-rw-r--r-- | test/trigger1.test | 1 | ||||
-rw-r--r-- | test/trigger3.test | 6 | ||||
-rw-r--r-- | test/unique.test | 8 |
16 files changed, 102 insertions, 40 deletions
@@ -1,5 +1,5 @@ -C Add\sextended\serror\scodes\sfor\sconstraint\serrors. -D 2013-02-09T13:58:25.162 +C Rename\sSQLITE_CONSTRAINT_RAISE\sto\sSQLITE_CONSTRAINT_TRIGGER.\s\sPut\sthe\s\nextended\sconstraint\serror\scodes\sin\salphabetical\sorder.\s\sAdd\smany\stest\scases\nfor\sthe\sextended\sconstraint\serror\scodes. +D 2013-02-09T15:37:11.109 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -130,7 +130,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 9b8d308979114991e5dc7cee958316e07186941d -F src/expr.c 44714c8f0e553de54e9648815ef940b20eb6fb4b +F src/expr.c f6c20285bd36e87ec47f4d840e90a32755e2a90c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 F src/func.c 8147799b048065a1590805be464d05b4913e652c @@ -176,7 +176,7 @@ F src/resolve.c 652ae6dc0f185b01b4536bb2fa7d878f13f0f1df F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 741c623c70c09b5fbe55d8ae6413d9215c1dedbf F src/shell.c 266791241d7add796ccce2317977ae6c3c67d77f -F src/sqlite.h.in 7cf6485b8a5cd88139e9d05c2a73368dd79863af +F src/sqlite.h.in 6296506a8fba279d8fa31f4abf01ab0cc92738a6 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 8e01aa31d5337ca0c0d0000745994f63762ec1bb @@ -184,7 +184,7 @@ F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 3213f3101e3b85f047d6e389da5a53d76d3d7540 -F src/test1.c ca2a9870a6654dd6d5b8fe5666e64ac31b6647f2 +F src/test1.c 50003e3beccad5569f757598fc7ce81b4f21aa7e F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa @@ -316,7 +316,7 @@ F test/boundary4.tcl 0bb4b1a94f4fc5ae59b79b9a2b7a140c405e2983 F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0 F test/cache.test f64136b0893c293d0b910ed057b3b711249099a7 -F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360 +F test/capi2.test e8b18cc61090b6e5e388f54d6b125d711d1b265a F test/capi3.test 56ab450125ead38846cbae7e5b6a216686c3cffa F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test 93d24621c9ff84da9da060f30431e0453db1cdb0 @@ -337,7 +337,7 @@ F test/collate9.test 3adcc799229545940df2f25308dd1ad65869145a F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 087c42997754b8c648819832241daf724f813322 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b -F test/conflict.test cabc41f7616675df71b4fddabca3bd5d9221915a +F test/conflict.test 0b3922d2304a14a47e3ccd61bbd6824327af659b F test/corrupt.test 4aabd06cff3fe759e3e658bcc17b71789710665e F test/corrupt2.test 9c0ab4becd50e9050bc1ebb8675456a4e5587bf0 F test/corrupt3.test 889d7cdb811800303aa722d7813fe8a4299cf726 @@ -400,7 +400,7 @@ F test/enc2.test 796c59832e2b9a52842f382ffda8f3e989db03ad F test/enc3.test 90683ad0e6ea587b9d5542ca93568af9a9858c40 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020 F test/eqp.test 46aa946dd55c90635327898275d3e533d23a9845 -F test/errmsg.test 3bb606db9d040cc6854459f8f5e5a2bcd9b7fd2a +F test/errmsg.test 050717f1c6a5685de9c79f5f9f6b83d7c592f73a F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3 F test/exclusive.test a1b324cb21834a490cd052d409d34789cfef57cb F test/exclusive2.test 372be98f6de44dd78734e364b7b626ea211761a6 @@ -411,9 +411,9 @@ F test/fallocate.test b5d34437bd7ab01d41b1464b8117aefd4d32160e F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a F test/filefmt.test dbee33e57818249cdffbbb7b13464635217beff1 F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da -F test/fkey2.test 5aa44e7153928a1f002803f94aaab4c76a7ceac2 +F test/fkey2.test 06e0b4cc9e1b3271ae2ae6feeb19755468432111 F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e -F test/fkey4.test c6c8f9f9be885f95c85c7bceb26f243ad906fd49 +F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 0bf64f2d19ad80433ca0b24edbf604a18b353d5f F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -519,7 +519,7 @@ F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 F test/fuzzer1.test a2e93bb1e19513dd6bf9c63d3d7c4673c983ca19 F test/fuzzerfault.test ff2282c81797b6a355f0748d8b54c7287c5d2b25 -F test/hook.test 5f3749de6462a6b87b4209b74adf7df5ac2df639 +F test/hook.test 45cb22b940c3cc0af616ba7430f666e245711a48 F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4 F test/in.test 5941096407d8c133b9eff15bd3e666624b6cbde3 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75 @@ -638,7 +638,7 @@ F test/nan.test e9648b9d007c7045242af35e11a984d4b169443a F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf F test/notify2.test 9503e51b9a272a5405c205ad61b7623d5a9ca489 F test/notify3.test a86259abbfb923aa27d30f0fc038c88e5251488a -F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 +F test/notnull.test 2afad748d18fd66d01f66463de73b3e2501fb226 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/orderby1.test f33968647da5c546528fe4d2bf86c6a6a2e5a7ae @@ -752,7 +752,7 @@ F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test 51edd31c65ed1560dd600b1796e8325df96318e2 F test/temptrigger.test 26670ed7a39cf2296a7f0a9e0a1d7bdb7abe936d -F test/tester.tcl 2f383e811010b05a83c0f00fc168cae1dd63a6d9 +F test/tester.tcl 0560b09498876da7714fff680c5d892b9228862f F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -897,9 +897,9 @@ F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 F test/trans2.test d5337e61de45e66b1fcbf9db833fa8c82e624b22 F test/trans3.test 373ac5183cc56be69f48ae44090e7f672939f732 F test/transitive1.test d04aa9023e425d6f2d4aa61dd81ee9e102f89062 -F test/trigger1.test 30f343f91586765874a28ad539c06f5a5f049931 +F test/trigger1.test dc47573ac79ffe0ee3eecaa517d70d8dacbccd03 F test/trigger2.test 834187beafd1db383af0c659cfa49b0576832816 -F test/trigger3.test d2c60d8be271c355d61727411e753181e877230a +F test/trigger3.test aa640bb2bbb03edd5ff69c055117ea088f121945 F test/trigger4.test 74700b76ebf3947b2f7a92405141eb2cf2a5d359 F test/trigger5.test 619391a3e9fc194081d22cefd830d811e7badf83 F test/trigger6.test 0e411654f122552da6590f0b4e6f781048a4a9b9 @@ -914,7 +914,7 @@ F test/tt3_checkpoint.c 415eccce672d681b297485fc20f44cdf0eac93af F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff F test/types2.test 3555aacf8ed8dc883356e59efc314707e6247a84 F test/types3.test 99e009491a54f4dc02c06bdbc0c5eea56ae3e25a -F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 +F test/unique.test cadb172bbd5a2e83cd644d186ccd602085e54edc F test/unixexcl.test a9870e46cc6f8390a494513d4f2bf55b5a8b3e46 F test/unordered.test 93dce7b6c97a817a4fe26980c484605a4511f614 F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 @@ -1034,10 +1034,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 4a7b4ee011fea911b981206c242e3d5553303b52 -R 270848b00a612583295cde2d6d289ebe -T *branch * constraint-error-codes -T *sym-constraint-error-codes * -T -sym-trunk * +P 5461104668a49529577f21df97f6a0e7d8f0c679 +R 3e5bf93d528119a300b3cfbe9643fae2 U drh -Z e6d281a3555aa6072b0a1a3d4e35cfe5 +Z 3cc6ac1c89181806262d74c582a3a1a8 diff --git a/manifest.uuid b/manifest.uuid index 697f1ff45..30c961384 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5461104668a49529577f21df97f6a0e7d8f0c679
\ No newline at end of file +3f67437536591a1b0742a25b983707933aaa16d5
\ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 51fa03695..5de468e21 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2935,7 +2935,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ sqlite3VdbeAddOp4( v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0); }else{ - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_RAISE, + sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER, pExpr->affinity, pExpr->u.zToken, 0); } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 3b55339ca..77bb02a34 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -479,15 +479,15 @@ int sqlite3_exec( #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) -#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (1<<8)) -#define SQLITE_CONSTRAINT_RAISE (SQLITE_CONSTRAINT | (2<<8)) +#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) +#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8)) -#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (4<<8)) -#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (5<<8)) -#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (6<<8)) -#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (7<<8)) -#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (8<<8)) -#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (9<<8)) +#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8)) +#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) +#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) +#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) +#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) +#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) /* ** CAPI3REF: Flags For File Open Operations diff --git a/src/test1.c b/src/test1.c index c8faa31dd..247fc872f 100644 --- a/src/test1.c +++ b/src/test1.c @@ -139,7 +139,7 @@ const char *sqlite3TestErrorName(int rc){ case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break; case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break; case SQLITE_CONSTRAINT_UNIQUE: zName = "SQLITE_CONSTRAINT_UNIQUE"; break; - case SQLITE_CONSTRAINT_RAISE: zName = "SQLITE_CONSTRAINT_RAISE"; break; + case SQLITE_CONSTRAINT_TRIGGER: zName = "SQLITE_CONSTRAINT_TRIGGER";break; case SQLITE_CONSTRAINT_FOREIGNKEY: zName = "SQLITE_CONSTRAINT_FOREIGNKEY"; break; case SQLITE_CONSTRAINT_CHECK: zName = "SQLITE_CONSTRAINT_CHECK"; break; diff --git a/test/capi2.test b/test/capi2.test index 8b36ac692..20ee3401b 100644 --- a/test/capi2.test +++ b/test/capi2.test @@ -235,8 +235,9 @@ do_test capi2-3.13 { do_test capi2-3.13b {db changes} {0} do_test capi2-3.14 { - list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] -} {SQLITE_CONSTRAINT {column a is not unique}} + list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] \ + [sqlite3_extended_errcode $DB] +} {SQLITE_CONSTRAINT {column a is not unique} SQLITE_CONSTRAINT_UNIQUE} do_test capi2-3.15 { set VM [sqlite3_prepare $DB {CREATE TABLE t2(a NOT NULL, b)} -1 TAIL] set TAIL @@ -258,8 +259,9 @@ do_test capi2-3.18 { [get_column_names $VM] } {SQLITE_ERROR 0 {} {}} do_test capi2-3.19 { - list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] -} {SQLITE_CONSTRAINT {t2.a may not be NULL}} + list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] \ + [sqlite3_extended_errcode $DB] +} {SQLITE_CONSTRAINT {t2.a may not be NULL} SQLITE_CONSTRAINT_NOTNULL} do_test capi2-3.20 { execsql { @@ -278,8 +280,8 @@ do_test capi2-3.23 { sqlite3_finalize $VM } {SQLITE_CONSTRAINT} do_test capi2-3.24 { - sqlite3_errcode $DB -} {SQLITE_CONSTRAINT} + list [sqlite3_errcode $DB] [sqlite3_extended_errcode $DB] +} {SQLITE_CONSTRAINT SQLITE_CONSTRAINT_UNIQUE} # Two or more virtual machines exists at the same time. # diff --git a/test/conflict.test b/test/conflict.test index 17c7263f1..657695960 100644 --- a/test/conflict.test +++ b/test/conflict.test @@ -580,6 +580,7 @@ do_test conflict-9.19 { SELECT * FROM t2; } } {1 {column e is not unique}} +verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE do_test conflict-9.20 { catch {execsql {COMMIT}} execsql {SELECT * FROM t3} @@ -592,6 +593,7 @@ do_test conflict-9.21 { SELECT * FROM t2; } } {1 {column e is not unique}} +verify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE do_test conflict-9.22 { catch {execsql {COMMIT}} execsql {SELECT * FROM t3} @@ -781,6 +783,7 @@ do_test conflict-12.3 { UPDATE t5 SET a=a+1 WHERE a=1; } } {1 {PRIMARY KEY must be unique}} +verify_ex_errcode conflict-12.3b SQLITE_CONSTRAINT_PRIMARYKEY do_test conflict-12.4 { execsql { UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1; @@ -802,6 +805,7 @@ do_test conflict-13.1 { REPLACE INTO t13 VALUES(2); } } {1 {constraint failed}} +verify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK do_test conflict-13.2 { execsql { REPLACE INTO t13 VALUES(3); diff --git a/test/errmsg.test b/test/errmsg.test index 9f8409b14..6b3f3b7db 100644 --- a/test/errmsg.test +++ b/test/errmsg.test @@ -80,12 +80,14 @@ do_test 2.2 { SQLITE_ERROR {SQL logic error or missing database} SQLITE_CONSTRAINT {column b is not unique} }] +verify_ex_errcode 2.2b SQLITE_CONSTRAINT_UNIQUE do_test 2.3 { error_messages_v2 "INSERT INTO t1 VALUES('ghi', 'def')" } [list {*}{ SQLITE_CONSTRAINT {column b is not unique} SQLITE_CONSTRAINT {column b is not unique} }] +verify_ex_errcode 2.3b SQLITE_CONSTRAINT_UNIQUE #------------------------------------------------------------------------- # Test SQLITE_SCHEMA errors. And, for _v2(), test that if the schema diff --git a/test/fkey2.test b/test/fkey2.test index a72359878..3e5b27c1e 100644 --- a/test/fkey2.test +++ b/test/fkey2.test @@ -1433,10 +1433,12 @@ do_test fkey2-17.1.2 { set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy] sqlite3_step $STMT } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey2-17.1.2b SQLITE_CONSTRAINT_FOREIGNKEY ifcapable autoreset { do_test fkey2-17.1.3 { sqlite3_step $STMT } {SQLITE_CONSTRAINT} + verify_ex_errcode fkey2-17.1.3b SQLITE_CONSTRAINT_FOREIGNKEY } else { do_test fkey2-17.1.3 { sqlite3_step $STMT @@ -1445,6 +1447,7 @@ ifcapable autoreset { do_test fkey2-17.1.4 { sqlite3_finalize $STMT } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey2-17.1.4b SQLITE_CONSTRAINT_FOREIGNKEY do_test fkey2-17.1.5 { execsql { INSERT INTO one VALUES(2, 3, 4); @@ -1488,9 +1491,11 @@ do_test fkey2-17.1.12 { do_test fkey2-17.1.13 { sqlite3_step $STMT } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey2-17.1.13b SQLITE_CONSTRAINT_FOREIGNKEY do_test fkey2-17.1.14 { sqlite3_finalize $STMT } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey2-17.1.14b SQLITE_CONSTRAINT_FOREIGNKEY drop_all_tables do_test fkey2-17.2.1 { @@ -1644,9 +1649,11 @@ do_test fkey2-19.2 { sqlite3_bind_int $S 1 2 sqlite3_step $S } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey2-19.2b SQLITE_CONSTRAINT_FOREIGNKEY do_test fkey2-19.3 { sqlite3_reset $S } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey2-19.3b SQLITE_CONSTRAINT_FOREIGNKEY do_test fkey2-19.4 { sqlite3_bind_int $S 1 1 sqlite3_step $S diff --git a/test/fkey4.test b/test/fkey4.test index d6dd2fc8f..79cf66347 100644 --- a/test/fkey4.test +++ b/test/fkey4.test @@ -42,10 +42,12 @@ do_test fkey4-1.2 { set ::STMT1 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] sqlite3_step $::STMT1 } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey4-1.2b SQLITE_CONSTRAINT_FOREIGNKEY do_test fkey4-1.3 { set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] sqlite3_step $::STMT2 } {SQLITE_CONSTRAINT} +verify_ex_errcode fkey4-1.3b SQLITE_CONSTRAINT_FOREIGNKEY do_test fkey4-1.4 { db eval {SELECT * FROM t2} } {1 3} diff --git a/test/hook.test b/test/hook.test index a195275c9..6346cc77a 100644 --- a/test/hook.test +++ b/test/hook.test @@ -74,6 +74,7 @@ do_test hook-3.6 { INSERT INTO t2 VALUES(6,7); } } {1 {constraint failed}} +verify_ex_errcode hook-3.6b SQLITE_CONSTRAINT_COMMITHOOK do_test hook-3.7 { set ::commit_cnt } {1 2 2 3 3 4 4 5 5 6 6 7} diff --git a/test/notnull.test b/test/notnull.test index 240aaba9d..01738a455 100644 --- a/test/notnull.test +++ b/test/notnull.test @@ -48,6 +48,7 @@ do_test notnull-1.2 { SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-1.2b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.3 { catchsql { DELETE FROM t1; @@ -62,6 +63,7 @@ do_test notnull-1.4 { SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-1.4b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.5 { catchsql { DELETE FROM t1; @@ -69,6 +71,7 @@ do_test notnull-1.5 { SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-1.5b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.6 { catchsql { DELETE FROM t1; @@ -104,6 +107,7 @@ do_test notnull-1.10 { SELECT * FROM t1 order by a; } } {1 {t1.b may not be NULL}} +verify_ex_errcode notnull-1.10b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.11 { catchsql { DELETE FROM t1; @@ -146,6 +150,7 @@ do_test notnull-1.16 { SELECT * FROM t1 order by a; } } {1 {t1.c may not be NULL}} +verify_ex_errcode notnull-1.16b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.17 { catchsql { DELETE FROM t1; @@ -153,6 +158,7 @@ do_test notnull-1.17 { SELECT * FROM t1 order by a; } } {1 {t1.d may not be NULL}} +verify_ex_errcode notnull-1.17b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.18 { catchsql { DELETE FROM t1; @@ -174,6 +180,7 @@ do_test notnull-1.20 { SELECT * FROM t1 order by a; } } {1 {t1.e may not be NULL}} +verify_ex_errcode notnull-1.20b SQLITE_CONSTRAINT_NOTNULL do_test notnull-1.21 { catchsql { DELETE FROM t1; @@ -190,6 +197,7 @@ do_test notnull-2.1 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-2.1b SQLITE_CONSTRAINT_NOTNULL do_test notnull-2.2 { catchsql { DELETE FROM t1; @@ -198,6 +206,7 @@ do_test notnull-2.2 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-2.2b SQLITE_CONSTRAINT_NOTNULL do_test notnull-2.3 { catchsql { DELETE FROM t1; @@ -214,6 +223,7 @@ do_test notnull-2.4 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-2.4b SQLITE_CONSTRAINT_NOTNULL do_test notnull-2.5 { catchsql { DELETE FROM t1; @@ -222,6 +232,7 @@ do_test notnull-2.5 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.b may not be NULL}} +verify_ex_errcode notnull-2.6b SQLITE_CONSTRAINT_NOTNULL do_test notnull-2.6 { catchsql { DELETE FROM t1; @@ -262,6 +273,7 @@ do_test notnull-2.10 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.e may not be NULL}} +verify_ex_errcode notnull-2.10b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.0 { execsql { @@ -287,6 +299,7 @@ do_test notnull-3.2 { SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-3.2b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.3 { catchsql { DELETE FROM t1; @@ -301,6 +314,7 @@ do_test notnull-3.4 { SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-3.4b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.5 { catchsql { DELETE FROM t1; @@ -308,6 +322,7 @@ do_test notnull-3.5 { SELECT * FROM t1 order by a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-3.5b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.6 { catchsql { DELETE FROM t1; @@ -343,6 +358,7 @@ do_test notnull-3.10 { SELECT * FROM t1 order by a; } } {1 {t1.b may not be NULL}} +verify_ex_errcode notnull-3.10b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.11 { catchsql { DELETE FROM t1; @@ -385,6 +401,7 @@ do_test notnull-3.16 { SELECT * FROM t1 order by a; } } {1 {t1.c may not be NULL}} +verify_ex_errcode notnull-3.16b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.17 { catchsql { DELETE FROM t1; @@ -392,6 +409,7 @@ do_test notnull-3.17 { SELECT * FROM t1 order by a; } } {1 {t1.d may not be NULL}} +verify_ex_errcode notnull-3.17b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.18 { catchsql { DELETE FROM t1; @@ -413,6 +431,7 @@ do_test notnull-3.20 { SELECT * FROM t1 order by a; } } {1 {t1.e may not be NULL}} +verify_ex_errcode notnull-3.20b SQLITE_CONSTRAINT_NOTNULL do_test notnull-3.21 { catchsql { DELETE FROM t1; @@ -429,6 +448,7 @@ do_test notnull-4.1 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-4.1b SQLITE_CONSTRAINT_NOTNULL do_test notnull-4.2 { catchsql { DELETE FROM t1; @@ -437,6 +457,7 @@ do_test notnull-4.2 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-4.2b SQLITE_CONSTRAINT_NOTNULL do_test notnull-4.3 { catchsql { DELETE FROM t1; @@ -453,6 +474,7 @@ do_test notnull-4.4 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.a may not be NULL}} +verify_ex_errcode notnull-4.4b SQLITE_CONSTRAINT_NOTNULL do_test notnull-4.5 { catchsql { DELETE FROM t1; @@ -461,6 +483,7 @@ do_test notnull-4.5 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.b may not be NULL}} +verify_ex_errcode notnull-4.5b SQLITE_CONSTRAINT_NOTNULL do_test notnull-4.6 { catchsql { DELETE FROM t1; @@ -501,6 +524,7 @@ do_test notnull-4.10 { SELECT * FROM t1 ORDER BY a; } } {1 {t1.e may not be NULL}} +verify_ex_errcode notnull-4.10b SQLITE_CONSTRAINT_NOTNULL # Test that bug 29ab7be99f is fixed. # @@ -519,6 +543,7 @@ do_test notnull-5.2 { INSERT INTO t1 SELECT * FROM t2; } } {1 {t1.b may not be NULL}} +verify_ex_errcode notnull-5.2b SQLITE_CONSTRAINT_NOTNULL do_test notnull-5.3 { execsql { SELECT * FROM t1 } } {1 2} @@ -531,9 +556,9 @@ do_test notnull-5.4 { COMMIT; } } {1 {t1.b may not be NULL}} +verify_ex_errcode notnull-5.4b SQLITE_CONSTRAINT_NOTNULL do_test notnull-5.5 { execsql { SELECT * FROM t1 } } {1 2} finish_test - diff --git a/test/tester.tcl b/test/tester.tcl index d3fa607d3..a7e6c9958 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -54,6 +54,7 @@ # do_ioerr_test TESTNAME ARGS... # crashsql ARGS... # integrity_check TESTNAME ?DB? +# verify_ex_errcode TESTNAME EXPECTED ?DB? # do_test TESTNAME SCRIPT EXPECTED # do_execsql_test TESTNAME SQL EXPECTED # do_catchsql_test TESTNAME SQL EXPECTED @@ -968,6 +969,12 @@ proc integrity_check {name {db db}} { } } +# Check the extended error code +# +proc verify_ex_errcode {name expected {db db}} { + do_test $name [list sqlite3_extended_errcode $db] $expected +} + # Return true if the SQL statement passed as the second argument uses a # statement transaction. diff --git a/test/trigger1.test b/test/trigger1.test index c49bc659a..1ebe12c89 100644 --- a/test/trigger1.test +++ b/test/trigger1.test @@ -423,6 +423,7 @@ do_test trigger1-6.2 { do_test trigger1-6.3 { catchsql {DELETE FROM t2} } {1 {deletes are not permitted}} +verify_ex_errcode trigger1-6.3b SQLITE_CONSTRAINT_TRIGGER do_test trigger1-6.4 { execsql {SELECT * FROM t2} } {3 4 7 8} diff --git a/test/trigger3.test b/test/trigger3.test index 34d19700f..fe91b9dcf 100644 --- a/test/trigger3.test +++ b/test/trigger3.test @@ -45,6 +45,7 @@ do_test trigger3-1.1 { INSERT INTO tbl VALUES (1, 5, 6); } } {1 {Trigger abort}} +verify_ex_errcode trigger3-1.1b SQLITE_CONSTRAINT_TRIGGER do_test trigger3-1.2 { execsql { SELECT * FROM tbl; @@ -63,6 +64,7 @@ do_test trigger3-2.1 { INSERT INTO tbl VALUES (2, 5, 6); } } {1 {Trigger fail}} +verify_ex_errcode trigger3-2.1b SQLITE_CONSTRAINT_TRIGGER do_test trigger3-2.2 { execsql { SELECT * FROM tbl; @@ -77,6 +79,7 @@ do_test trigger3-3.1 { INSERT INTO tbl VALUES (3, 5, 6); } } {1 {Trigger rollback}} +verify_ex_errcode trigger3-3.1b SQLITE_CONSTRAINT_TRIGGER do_test trigger3-3.2 { execsql { SELECT * FROM tbl; @@ -92,6 +95,7 @@ do_test trigger3-3.3 { INSERT INTO tbl VALUES (3, 9, 10); } } {1 {Trigger rollback}} +verify_ex_errcode trigger3-3.3b SQLITE_CONSTRAINT_TRIGGER do_test trigger3-3.4 { execsql {SELECT * FROM tbl} } {} @@ -172,6 +176,7 @@ do_test trigger3-7.1 { INSERT INTO tbl_view VALUES(1, 2, 3); } } {1 {View rollback}} +verify_ex_errcode trigger3-7.1b SQLITE_CONSTRAINT_TRIGGER do_test trigger3-7.2 { catchsql { INSERT INTO tbl_view VALUES(2, 2, 3); @@ -182,6 +187,7 @@ do_test trigger3-7.3 { INSERT INTO tbl_view VALUES(3, 2, 3); } } {1 {View abort}} +verify_ex_errcode trigger3-7.3b SQLITE_CONSTRAINT_TRIGGER } ;# ifcapable view diff --git a/test/unique.test b/test/unique.test index 56c49eed4..eac19b59e 100644 --- a/test/unique.test +++ b/test/unique.test @@ -48,6 +48,7 @@ do_test unique-1.3 { INSERT INTO t1(a,b,c) VALUES(1,3,4) } } {1 {column a is not unique}} +verify_ex_errcode unique-1.3b SQLITE_CONSTRAINT_UNIQUE do_test unique-1.4 { execsql { SELECT * FROM t1 ORDER BY a; @@ -58,6 +59,7 @@ do_test unique-1.5 { INSERT INTO t1(a,b,c) VALUES(3,2,4) } } {1 {column b is not unique}} +verify_ex_errcode unique-1.5b SQLITE_CONSTRAINT_UNIQUE do_test unique-1.6 { execsql { SELECT * FROM t1 ORDER BY a; @@ -99,6 +101,7 @@ do_test unique-2.3 { INSERT INTO t2 VALUES(1,5); } } {1 {column a is not unique}} +verify_ex_errcode unique-2.3b SQLITE_CONSTRAINT_UNIQUE do_test unique-2.4 { catchsql { SELECT * FROM t2 ORDER BY a @@ -125,6 +128,7 @@ do_test unique-2.8 { CREATE UNIQUE INDEX i2 ON t2(a); } } {1 {indexed columns are not unique}} +verify_ex_errcode unique-2.8b SQLITE_CONSTRAINT_UNIQUE do_test unique-2.9 { catchsql { CREATE INDEX i2 ON t2(a); @@ -163,6 +167,7 @@ do_test unique-3.4 { SELECT * FROM t3 ORDER BY a,b,c,d; } } {1 {columns a, c, d are not unique}} +verify_ex_errcode unique-3.4b SQLITE_CONSTRAINT_UNIQUE integrity_check unique-3.5 # Make sure NULLs are distinct as far as the UNIQUE tests are @@ -217,6 +222,7 @@ do_test unique-4.9 { do_test unique-4.10 { catchsql {CREATE UNIQUE INDEX i4c ON t4(b)} } {1 {indexed columns are not unique}} +verify_ex_errcode unique-4.10b SQLITE_CONSTRAINT_UNIQUE integrity_check unique-4.99 # Test the error message generation logic. In particular, make sure we @@ -249,5 +255,7 @@ do_test unique-5.2 { 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, sixth_column_with_long_name are not unique}} +verify_ex_errcode unique-5.2b SQLITE_CONSTRAINT_UNIQUE + finish_test |