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