Fix CHECK constraints to use alternative conflict resolution. Ticket #1717. (CVS 3137)
FossilOrigin-Name: c0d20fa97f94313e6b7ee5b4baa236ef5b664d76
This commit is contained in:
parent
afed086386
commit
aa01c7e2cd
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Set\sand\sclear\sthe\sfull_column_name\sflag\susing\sdirect\sinvocation\srather\sthan\nthe\sexecsql\stcl\scommand\sso\sthat\sthe\sselect1\stest\sworks\swith\sthe\sserialized\nstatement\sextension.\s(CVS\s3136)
|
||||
D 2006-03-14T13:10:43
|
||||
C Fix\sCHECK\sconstraints\sto\suse\salternative\sconflict\sresolution.\s\sTicket\s#1717.\s(CVS\s3137)
|
||||
D 2006-03-15T16:26:10
|
||||
F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
|
||||
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -46,7 +46,7 @@ F src/expr.c 105e8e17babd4dec832d4a0c88bea12ec074cbbe
|
||||
F src/func.c ea1a4480bacfb17f8e08d675313f024fe7136c00
|
||||
F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
|
||||
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
|
||||
F src/insert.c 2b0eb1f7d50b1d94782bac9644b41a53cf65c019
|
||||
F src/insert.c 1ae4b8ff5549497808e1b57b9243abcb599fd02f
|
||||
F src/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390
|
||||
F src/main.c 631ad93d030f0cef159eb98be173cdd472c5d3b0
|
||||
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
|
||||
@ -136,7 +136,7 @@ F test/capi2.test cddd151c7b687e9e00fde408b9547ec93c2146a4
|
||||
F test/capi3.test 6553fb89a4d6918e42b5f953c1d880bacb6917fe
|
||||
F test/capi3b.test 5f0bc94b104e11086b1103b20277e1910f59c7f4
|
||||
F test/cast.test f88e7b6946e9a467cf4bb142d92bb65a83747fc2
|
||||
F test/check.test 55ad950d7ad24d6eb3328c54149f90d38a39a962
|
||||
F test/check.test 46c658566c2501faa3f91b941654119703da1f83
|
||||
F test/collate1.test add9454cef160677bb8b34148b8f277ce7f9f1c4
|
||||
F test/collate2.test 224a632ba04907c049804b08162efd234aa7871f
|
||||
F test/collate3.test 947a77f5b8227e037a7094d0e338a5504f155cc4
|
||||
@ -333,7 +333,7 @@ F www/fullscanb.gif f7c94cb227f060511f8909e10f570157263e9a25
|
||||
F www/index-ex1-x-b.gif f9b1d85c3fa2435cf38b15970c7e3aa1edae23a3
|
||||
F www/index.tcl 9c659eec487d5e9196d4125ab200cfc86e93528d
|
||||
F www/indirect1b1.gif adfca361d2df59e34f9c5cac52a670c2bfc303a1
|
||||
F www/lang.tcl 53a3643fe8a1f2397a0be00527eb26e4c801c0ae
|
||||
F www/lang.tcl 9fe2b8bb0a3158f4b629e184f5db9f895ecbb4cd
|
||||
F www/lockingv3.tcl f59b19d6c8920a931f096699d6faaf61c05db55f
|
||||
F www/mingw.tcl d96b451568c5d28545fefe0c80bee3431c73f69c
|
||||
F www/nulls.tcl ec35193f92485b87b90a994a01d0171b58823fcf
|
||||
@ -355,7 +355,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P f07181739f82b0d23f934f51b97e67c32efe6f42
|
||||
R 2f1c4b3a9a42e21655f80f86a32ab92a
|
||||
P 4d70013a6a42a58bc7af3a87bf79c131a0070e96
|
||||
R 21ca7022b824f24e0d9e1adce9350a21
|
||||
U drh
|
||||
Z f9b20f77c14e1ce189c3b40b91bc6cce
|
||||
Z 3a90d1df6d7d6a018bd1a142c92b17e6
|
||||
|
@ -1 +1 @@
|
||||
4d70013a6a42a58bc7af3a87bf79c131a0070e96
|
||||
c0d20fa97f94313e6b7ee5b4baa236ef5b664d76
|
10
src/insert.c
10
src/insert.c
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle INSERT statements in SQLite.
|
||||
**
|
||||
** $Id: insert.c,v 1.163 2006/03/06 20:55:46 drh Exp $
|
||||
** $Id: insert.c,v 1.164 2006/03/15 16:26:10 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -874,7 +874,13 @@ void sqlite3GenerateConstraintChecks(
|
||||
sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1);
|
||||
assert( pParse->ckOffset==nCol );
|
||||
pParse->ckOffset = 0;
|
||||
sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, OE_Abort);
|
||||
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
|
||||
if( onError==OE_Ignore || onError==OE_Replace ){
|
||||
sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0);
|
||||
sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest);
|
||||
}else{
|
||||
sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
|
||||
}
|
||||
sqlite3VdbeResolveLabel(v, allOk);
|
||||
}
|
||||
#endif /* !defined(SQLITE_OMIT_CHECK) */
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing CHECK constraints
|
||||
#
|
||||
# $Id: check.test,v 1.8 2006/01/17 09:35:02 danielk1977 Exp $
|
||||
# $Id: check.test,v 1.9 2006/03/15 16:26:10 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -295,6 +295,55 @@ do_test check-5.2 {
|
||||
}
|
||||
} {1 {parameters prohibited in CHECK constraints}}
|
||||
|
||||
do_test check-6.1 {
|
||||
execsql {SELECT * FROM t1}
|
||||
} {4 11.0}
|
||||
do_test check-6.2 {
|
||||
execsql {
|
||||
UPDATE OR IGNORE t1 SET x=5;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {4 11.0}
|
||||
do_test check-6.3 {
|
||||
execsql {
|
||||
INSERT OR IGNORE INTO t1 VALUES(5,4.0);
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {4 11.0}
|
||||
do_test check-6.4 {
|
||||
execsql {
|
||||
INSERT OR IGNORE INTO t1 VALUES(2,20.0);
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {4 11.0 2 20.0}
|
||||
do_test check-6.5 {
|
||||
catchsql {
|
||||
UPDATE OR FAIL t1 SET x=7-x, y=y+1;
|
||||
}
|
||||
} {1 {constraint failed}}
|
||||
do_test check-6.6 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {3 12.0 2 20.0}
|
||||
do_test check-6.7 {
|
||||
catchsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(1,30.0);
|
||||
INSERT OR ROLLBACK INTO t1 VALUES(8,40.0);
|
||||
}
|
||||
} {1 {constraint failed}}
|
||||
do_test check-6.8 {
|
||||
catchsql {
|
||||
COMMIT;
|
||||
}
|
||||
} {1 {cannot commit - no transaction is active}}
|
||||
do_test check-6.9 {
|
||||
execsql {
|
||||
SELECT * FROM t1
|
||||
}
|
||||
} {3 12.0 2 20.0}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Run this Tcl script to generate the lang-*.html files.
|
||||
#
|
||||
set rcsid {$Id: lang.tcl,v 1.110 2006/02/15 17:30:31 drh Exp $}
|
||||
set rcsid {$Id: lang.tcl,v 1.111 2006/03/15 16:26:10 drh Exp $}
|
||||
source common.tcl
|
||||
|
||||
if {[llength $argv]>0} {
|
||||
@ -1521,11 +1521,12 @@ or updating the current row. Thus the insert or update always occurs.
|
||||
The command continues executing normally. No error is returned.
|
||||
If a NOT NULL constraint violation occurs, the NULL value is replaced
|
||||
by the default value for that column. If the column has no default
|
||||
value, then the ABORT algorithm is used.</p>
|
||||
value, then the ABORT algorithm is used. If a CHECK constraint violation
|
||||
occurs then the IGNORE algorithm is used.</p>
|
||||
|
||||
<p>When this conflict resolution strategy deletes rows in order to
|
||||
satisfy a constraint, it does not invoke delete triggers on those
|
||||
rows. But that may change in a future release.</p>
|
||||
rows. This behavior might change in a future release.</p>
|
||||
</dl>
|
||||
|
||||
<p>The algorithm specified in the OR clause of a INSERT or UPDATE
|
||||
|
Loading…
x
Reference in New Issue
Block a user