Better testing of the ON CONFLICT logic. (CVS 358)

FossilOrigin-Name: 9bbddb8e013b47547164f71f2d7abd995f8d7385
This commit is contained in:
drh 2002-01-30 04:32:00 +00:00
parent bb37fdc782
commit ef6764a1d9
6 changed files with 645 additions and 20 deletions

View File

@ -1,5 +1,5 @@
C More\sbug\sfixes\sin\sthe\sON\sCONFLICT\senhancement.\s(CVS\s357)
D 2002-01-30T00:54:56
C Better\stesting\sof\sthe\sON\sCONFLICT\slogic.\s(CVS\s358)
D 2002-01-30T04:32:01
F Makefile.in 9fa4277413bf1d9cf91365f07d4108d7d87ed2af
F Makefile.template 3e26a3b9e7aee1b811deaf673e8d8973bdb3f22d
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@ -23,10 +23,10 @@ F src/btree.c c796e387da340cb628dc1e41f684fc20253f561e
F src/btree.h 9ead7f54c270d8a554e59352ca7318fdaf411390
F src/build.c c55881f270b1a77d1025dcfba7c87db46d43a9d0
F src/delete.c 4cdb6d2e94e2eb1b1aa79eefafd4669d43c249d6
F src/expr.c 4cae8bf44d5732182e5e8c25b4552c05ea55593e
F src/expr.c a2a87dbd411a508ff89dffa90505ad42dac2f920
F src/hash.c 8f7c740ef2eaaa8decfa8751f2be30680b123e46
F src/hash.h a5f5b3ce2d086a172c5879b0b06a27a82eac9fac
F src/insert.c b942f99e4f4c0464f51ad171b6edbc1439fac893
F src/insert.c 5de9d85889d4b97c823be1b9ebf01c30e29947b3
F src/main.c 0205771a6c31a9858ff131fc1e797b589afb76bf
F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c
F src/os.c c615faa4d23e742e0650e0751a6ad2a18438ad53
@ -57,7 +57,7 @@ F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
F test/btree.test 6ab4dc5f595905a276ef588fad3c9236dc07a47b
F test/btree2.test 08e9485619265cbaf5d11bd71f357cdc26bb87e0
F test/btree3.test 9caa9e22491dd8cd8aa36d7ac3b48b089817c895
F test/conflict.test b1115520b32fe682dfd161754ed634352ab476af
F test/conflict.test 66ac8bec8e25224b6aca18d76dd40b0afa27e227
F test/copy.test 768e6f1701a07d08090e1ca7f7dcce0a7a72b43e
F test/delete.test c904a62129fe102b314a96111a8417f10249e4d8
F test/expr.test c8a495050dcec3f9e68538c3ef466726933302c1
@ -73,6 +73,7 @@ F test/lock.test 19593689260c419efe7ced55b1418653a4b7bcd1
F test/main.test 1626345b5f630c5398eede500d9354813b76b0fd
F test/malloc.test 70fdd0812e2a57eb746aaf015350f58bb8eee0b1
F test/misc1.test 50a5ca3481fc1f3cd6b978bcd6ed04c06f26a1e6
F test/notnull.test 70856457c86fe50877f760e4057e99fdedd2997c
F test/pager.test 59bbc4e3d489529ed33db6e15595789e51056077
F test/printf.test 3cb415073754cb8ff076f26173143c3cd293a9da
F test/quick.test 6f023c7a73fc413e6d65b7a1879c79764038dc05
@ -120,7 +121,7 @@ F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P ac8a4189e2a0c41161ee359db25de94435420368
R d0474e87b43c8e56cdd7c7f610ed8044
P 8229b5f6a348a56432a4a609ee125520c5831973
R 6092c649bf38d0cb57a1ec35caeb9370
U drh
Z 06e7e93dabc09d9be0f533183ed3ad0f
Z 733d233a561b4a44b1706a6a61fc3f4e

View File

@ -1 +1 @@
8229b5f6a348a56432a4a609ee125520c5831973
9bbddb8e013b47547164f71f2d7abd995f8d7385

View File

@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.39 2002/01/22 14:11:29 drh Exp $
** $Id: expr.c,v 1.40 2002/01/30 04:32:01 drh Exp $
*/
#include "sqliteInt.h"
@ -573,16 +573,12 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){
}
break;
}
case TK_FLOAT:
case TK_INTEGER: {
sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);
break;
}
case TK_FLOAT: {
int addr = sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, addr, pExpr->token.z, pExpr->token.n);
break;
}
case TK_STRING: {
int addr = sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, addr, pExpr->token.z, pExpr->token.n);

View File

@ -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.36 2002/01/30 00:54:56 drh Exp $
** $Id: insert.c,v 1.37 2002/01/30 04:32:01 drh Exp $
*/
#include "sqliteInt.h"
@ -409,8 +409,8 @@ void sqliteGenerateConstraintChecks(
if( onError==OE_Replace && pTab->aCol[i].zDflt==0 ){
onError = OE_Abort;
}
addr = sqliteVdbeAddOp(v, OP_Dup, nCol-i, 1);
sqliteVdbeAddOp(v, OP_NotNull, 0, addr+1+(onError!=OE_Abort));
sqliteVdbeAddOp(v, OP_Dup, nCol-1-i, 1);
addr = sqliteVdbeAddOp(v, OP_NotNull, 0, 0);
switch( onError ){
case OE_Abort: {
sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, 0);
@ -429,6 +429,7 @@ void sqliteGenerateConstraintChecks(
}
default: assert(0);
}
sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v));
}
/* Test all CHECK constraints
@ -498,7 +499,7 @@ void sqliteGenerateConstraintChecks(
case OE_Replace: {
sqliteGenerateRowDelete(v, pTab, base);
if( isUpdate ){
sqliteVdbeAddOp(v, OP_Dup, nCol+extra+recnoChng, 1);
sqliteVdbeAddOp(v, OP_Dup, nCol+extra+1+recnoChng, 1);
sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
}
seenReplace = 1;

View File

@ -13,7 +13,7 @@
# This file implements tests for the conflict resolution extension
# to SQLite.
#
# $Id: conflict.test,v 1.1 2002/01/30 00:54:57 drh Exp $
# $Id: conflict.test,v 1.2 2002/01/30 04:32:01 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -144,5 +144,132 @@ do_test conflict-1.17 {
}
} {0 {1 3 3 2 3 5}}
do_test conflict-2.1 {
execsql {
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1(a integer primary key, b, c, UNIQUE(a,b));
CREATE INDEX t1b ON t1(b);
CREATE INDEX t1bc ON t1(b,c);
INSERT INTO t1 VALUES(1,2,3);
SELECT c FROM t1 ORDER BY c;
}
} {3}
do_test conflict-2.2 {
catchsql {
INSERT INTO t1 VALUES(1,2,4);
SELECT c FROM t1 ORDER BY c;
}
} {1 {constraint failed}}
do_test conflict-2.3 {
catchsql {
INSERT ON CONFLICT IGNORE INTO t1 VALUES(1,2,4);
SELECT c FROM t1 ORDER BY c;
}
} {0 3}
do_test conflict-2.4 {
catchsql {
INSERT ON CONFLICT REPLACE INTO t1 VALUES(1,2,4);
SELECT c FROM t1 ORDER BY c;
}
} {0 4}
do_test conflict-2.5 {
catchsql {
INSERT ON CONFLICT ABORT INTO t1 VALUES(1,2,5);
SELECT c FROM t1 ORDER BY c;
}
} {1 {constraint failed}}
do_test conflict-2.6 {
catchsql {
INSERT IGNORE INTO t1 VALUES(1,2,5);
SELECT c FROM t1 ORDER BY c;
}
} {0 4}
do_test conflict-2.7 {
catchsql {
INSERT REPLACE INTO t1 VALUES(1,2,5);
SELECT c FROM t1 ORDER BY c;
}
} {0 5}
do_test conflict-2.8 {
catchsql {
INSERT ON CONFLICT ABORT INTO t1 VALUES(1,2,6);
SELECT c FROM t1 ORDER BY c;
}
} {1 {constraint failed}}
do_test conflict-2.9 {
execsql {
BEGIN;
CREATE TABLE t2(a,b,c INTEGER PRIMARY KEY);
INSERT INTO t2 VALUES(1,2,11);
INSERT INTO t2 VALUES(1,2,12);
INSERT INTO t2 VALUES(1,2,13);
INSERT INTO t2 VALUES(1,2,14);
INSERT INTO t2 VALUES(2,2,21);
INSERT INTO t2 VALUES(2,2,22);
INSERT INTO t2 VALUES(2,2,23);
INSERT INTO t2 VALUES(2,2,24);
COMMIT;
SELECT count(*) FROM t2;
}
} 8
do_test conflict-2.10 {
catchsql {
INSERT IGNORE INTO t1 SELECT a,b,c FROM t2 ORDER BY c;
SELECT c FROM t1 ORDER BY c;
}
} {0 {5 21}}
do_test conflict-2.11 {
catchsql {
INSERT REPLACE INTO t1 SELECT a,b,c FROM t2 ORDER BY c;
SELECT c FROM t1 ORDER BY c;
}
} {0 {14 24}}
###### Fix me!
do_test conflict-2.12 {
catchsql {
INSERT REPLACE INTO t1 SELECT a,b,c FROM t2 ORDER BY c DESC;
SELECT c FROM t1 ORDER BY c;
}
} {0 {14 24}}
do_test conflict-2.13 {
execsql {
BEGIN;
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3);
INSERT INTO t1 VALUES(2,3,4);
INSERT INTO t1 VALUES(3,3,5);
COMMIT;
SELECT * FROM t1 ORDER BY c;
}
} {1 2 3 2 3 4 3 3 5}
do_test conflict-2.14 {
catchsql {
UPDATE ON CONFLICT ABORT t1 SET a=2, b=3 WHERE b=2;
SELECT c FROM t1 ORDER BY c;
}
} {1 {constraint failed}};
do_test conflict-2.15 {
catchsql {
UPDATE t1 SET a=2, b=3 WHERE b=2;
SELECT c FROM t1 ORDER BY c;
}
} {1 {constraint failed}};
do_test conflict-2.16 {
catchsql {
UPDATE ON CONFLICT IGNORE t1 SET a=2, b=3 WHERE b=2;
SELECT * FROM t1 ORDER BY c;
}
} {0 {1 2 3 2 3 4 3 3 5}}
do_test conflict-2.17 {
catchsql {
UPDATE ON CONFLICT REPLACE t1 SET a=2, b=3 WHERE b=2;
SELECT * FROM t1 ORDER BY c;
}
} {0 {2 3 3 3 3 5}}
finish_test

500
test/notnull.test Normal file
View File

@ -0,0 +1,500 @@
# 2002 January 29
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the NOT NULL constraint.
#
# $Id: notnull.test,v 1.1 2002/01/30 04:32:01 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test notnull-1.0 {
execsql {
CREATE TABLE t1 (
a NOT NULL,
b NOT NULL DEFAULT 5,
c NOT NULL REPLACE DEFAULT 6,
d NOT NULL IGNORE DEFAULT 7,
e NOT NULL ABORT DEFAULT 8
);
SELECT * FROM t1;
}
} {}
do_test notnull-1.1 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 3 4 5}}
do_test notnull-1.2 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.3 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {}}
do_test notnull-1.4 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.5 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.6 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-1.7 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-1.8 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-1.9 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-1.10 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.11 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {}}
do_test notnull-1.12 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-1.13 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 6 4 5}}
do_test notnull-1.14 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {0 {}}
do_test notnull-1.15 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 6 4 5}}
do_test notnull-1.16 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.17 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.18 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 3 7 5}}
do_test notnull-1.19 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);
SELECT * FROM t1 order by a;
}
} {0 {1 2 3 4 8}}
do_test notnull-1.20 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-1.21 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
SELECT * FROM t1 order by a;
}
} {0 {5 5 3 2 1}}
do_test notnull-2.1 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-2.2 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT REPLACE t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-2.3 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT IGNORE t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 3 4 5}}
do_test notnull-2.4 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT ABORT t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-2.5 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET b=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-2.6 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT REPLACE t1 SET b=null, d=e, e=d;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 5 3 5 4}}
do_test notnull-2.7 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT IGNORE t1 SET b=null, d=e, e=d;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 3 4 5}}
do_test notnull-2.8 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET c=null, d=e, e=d;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 6 5 4}}
do_test notnull-2.9 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET d=null, a=b, b=a;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 3 4 5}}
do_test notnull-2.10 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET e=null, a=b, b=a;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-3.0 {
execsql {
CREATE INDEX t1a ON t1(a);
CREATE INDEX t1b ON t1(b);
CREATE INDEX t1c ON t1(c);
CREATE INDEX t1d ON t1(d);
CREATE INDEX t1e ON t1(e);
CREATE INDEX t1abc ON t1(a,b,c);
}
} {}
do_test notnull-3.1 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 3 4 5}}
do_test notnull-3.2 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.3 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {}}
do_test notnull-3.4 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.5 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.6 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-3.7 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-3.8 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-3.9 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-3.10 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.11 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {}}
do_test notnull-3.12 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 5 3 4 5}}
do_test notnull-3.13 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 6 4 5}}
do_test notnull-3.14 {
catchsql {
DELETE FROM t1;
INSERT IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {0 {}}
do_test notnull-3.15 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 6 4 5}}
do_test notnull-3.16 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.17 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.18 {
catchsql {
DELETE FROM t1;
INSERT ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
SELECT * FROM t1 order by a;
}
} {0 {1 2 3 7 5}}
do_test notnull-3.19 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);
SELECT * FROM t1 order by a;
}
} {0 {1 2 3 4 8}}
do_test notnull-3.20 {
catchsql {
DELETE FROM t1;
INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
SELECT * FROM t1 order by a;
}
} {1 {constraint failed}}
do_test notnull-3.21 {
catchsql {
DELETE FROM t1;
INSERT REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
SELECT * FROM t1 order by a;
}
} {0 {5 5 3 2 1}}
do_test notnull-4.1 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-4.2 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT REPLACE t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-4.3 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT IGNORE t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 3 4 5}}
do_test notnull-4.4 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT ABORT t1 SET a=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-4.5 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET b=null;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
do_test notnull-4.6 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT REPLACE t1 SET b=null, d=e, e=d;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 5 3 5 4}}
do_test notnull-4.7 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE ON CONFLICT IGNORE t1 SET b=null, d=e, e=d;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 3 4 5}}
do_test notnull-4.8 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET c=null, d=e, e=d;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 6 5 4}}
do_test notnull-4.9 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET d=null, a=b, b=a;
SELECT * FROM t1 ORDER BY a;
}
} {0 {1 2 3 4 5}}
do_test notnull-4.10 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,3,4,5);
UPDATE t1 SET e=null, a=b, b=a;
SELECT * FROM t1 ORDER BY a;
}
} {1 {constraint failed}}
finish_test