xref: /titanic_50/usr/src/lib/libsqlite/test/notnull.test (revision c5c4113dfcabb1eed3d4bdf7609de5170027a794)
1*c5c4113dSnw141292
2*c5c4113dSnw141292#pragma ident	"%Z%%M%	%I%	%E% SMI"
3*c5c4113dSnw141292
4*c5c4113dSnw141292# 2002 January 29
5*c5c4113dSnw141292#
6*c5c4113dSnw141292# The author disclaims copyright to this source code.  In place of
7*c5c4113dSnw141292# a legal notice, here is a blessing:
8*c5c4113dSnw141292#
9*c5c4113dSnw141292#    May you do good and not evil.
10*c5c4113dSnw141292#    May you find forgiveness for yourself and forgive others.
11*c5c4113dSnw141292#    May you share freely, never taking more than you give.
12*c5c4113dSnw141292#
13*c5c4113dSnw141292#***********************************************************************
14*c5c4113dSnw141292# This file implements regression tests for SQLite library.
15*c5c4113dSnw141292#
16*c5c4113dSnw141292# This file implements tests for the NOT NULL constraint.
17*c5c4113dSnw141292#
18*c5c4113dSnw141292# $Id: notnull.test,v 1.3 2003/01/29 18:46:54 drh Exp $
19*c5c4113dSnw141292
20*c5c4113dSnw141292set testdir [file dirname $argv0]
21*c5c4113dSnw141292source $testdir/tester.tcl
22*c5c4113dSnw141292
23*c5c4113dSnw141292do_test notnull-1.0 {
24*c5c4113dSnw141292  execsql {
25*c5c4113dSnw141292    CREATE TABLE t1 (
26*c5c4113dSnw141292      a NOT NULL,
27*c5c4113dSnw141292      b NOT NULL DEFAULT 5,
28*c5c4113dSnw141292      c NOT NULL ON CONFLICT REPLACE DEFAULT 6,
29*c5c4113dSnw141292      d NOT NULL ON CONFLICT IGNORE DEFAULT 7,
30*c5c4113dSnw141292      e NOT NULL ON CONFLICT ABORT DEFAULT 8
31*c5c4113dSnw141292    );
32*c5c4113dSnw141292    SELECT * FROM t1;
33*c5c4113dSnw141292  }
34*c5c4113dSnw141292} {}
35*c5c4113dSnw141292do_test notnull-1.1 {
36*c5c4113dSnw141292  catchsql {
37*c5c4113dSnw141292    DELETE FROM t1;
38*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
39*c5c4113dSnw141292    SELECT * FROM t1 order by a;
40*c5c4113dSnw141292  }
41*c5c4113dSnw141292} {0 {1 2 3 4 5}}
42*c5c4113dSnw141292do_test notnull-1.2 {
43*c5c4113dSnw141292  catchsql {
44*c5c4113dSnw141292    DELETE FROM t1;
45*c5c4113dSnw141292    INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
46*c5c4113dSnw141292    SELECT * FROM t1 order by a;
47*c5c4113dSnw141292  }
48*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
49*c5c4113dSnw141292do_test notnull-1.3 {
50*c5c4113dSnw141292  catchsql {
51*c5c4113dSnw141292    DELETE FROM t1;
52*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
53*c5c4113dSnw141292    SELECT * FROM t1 order by a;
54*c5c4113dSnw141292  }
55*c5c4113dSnw141292} {0 {}}
56*c5c4113dSnw141292do_test notnull-1.4 {
57*c5c4113dSnw141292  catchsql {
58*c5c4113dSnw141292    DELETE FROM t1;
59*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
60*c5c4113dSnw141292    SELECT * FROM t1 order by a;
61*c5c4113dSnw141292  }
62*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
63*c5c4113dSnw141292do_test notnull-1.5 {
64*c5c4113dSnw141292  catchsql {
65*c5c4113dSnw141292    DELETE FROM t1;
66*c5c4113dSnw141292    INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
67*c5c4113dSnw141292    SELECT * FROM t1 order by a;
68*c5c4113dSnw141292  }
69*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
70*c5c4113dSnw141292do_test notnull-1.6 {
71*c5c4113dSnw141292  catchsql {
72*c5c4113dSnw141292    DELETE FROM t1;
73*c5c4113dSnw141292    INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
74*c5c4113dSnw141292    SELECT * FROM t1 order by a;
75*c5c4113dSnw141292  }
76*c5c4113dSnw141292} {0 {1 5 3 4 5}}
77*c5c4113dSnw141292do_test notnull-1.7 {
78*c5c4113dSnw141292  catchsql {
79*c5c4113dSnw141292    DELETE FROM t1;
80*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);
81*c5c4113dSnw141292    SELECT * FROM t1 order by a;
82*c5c4113dSnw141292  }
83*c5c4113dSnw141292} {0 {1 5 3 4 5}}
84*c5c4113dSnw141292do_test notnull-1.8 {
85*c5c4113dSnw141292  catchsql {
86*c5c4113dSnw141292    DELETE FROM t1;
87*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);
88*c5c4113dSnw141292    SELECT * FROM t1 order by a;
89*c5c4113dSnw141292  }
90*c5c4113dSnw141292} {0 {1 5 3 4 5}}
91*c5c4113dSnw141292do_test notnull-1.9 {
92*c5c4113dSnw141292  catchsql {
93*c5c4113dSnw141292    DELETE FROM t1;
94*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);
95*c5c4113dSnw141292    SELECT * FROM t1 order by a;
96*c5c4113dSnw141292  }
97*c5c4113dSnw141292} {0 {1 5 3 4 5}}
98*c5c4113dSnw141292do_test notnull-1.10 {
99*c5c4113dSnw141292  catchsql {
100*c5c4113dSnw141292    DELETE FROM t1;
101*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
102*c5c4113dSnw141292    SELECT * FROM t1 order by a;
103*c5c4113dSnw141292  }
104*c5c4113dSnw141292} {1 {t1.b may not be NULL}}
105*c5c4113dSnw141292do_test notnull-1.11 {
106*c5c4113dSnw141292  catchsql {
107*c5c4113dSnw141292    DELETE FROM t1;
108*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
109*c5c4113dSnw141292    SELECT * FROM t1 order by a;
110*c5c4113dSnw141292  }
111*c5c4113dSnw141292} {0 {}}
112*c5c4113dSnw141292do_test notnull-1.12 {
113*c5c4113dSnw141292  catchsql {
114*c5c4113dSnw141292    DELETE FROM t1;
115*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
116*c5c4113dSnw141292    SELECT * FROM t1 order by a;
117*c5c4113dSnw141292  }
118*c5c4113dSnw141292} {0 {1 5 3 4 5}}
119*c5c4113dSnw141292do_test notnull-1.13 {
120*c5c4113dSnw141292  catchsql {
121*c5c4113dSnw141292    DELETE FROM t1;
122*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
123*c5c4113dSnw141292    SELECT * FROM t1 order by a;
124*c5c4113dSnw141292  }
125*c5c4113dSnw141292} {0 {1 2 6 4 5}}
126*c5c4113dSnw141292do_test notnull-1.14 {
127*c5c4113dSnw141292  catchsql {
128*c5c4113dSnw141292    DELETE FROM t1;
129*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
130*c5c4113dSnw141292    SELECT * FROM t1 order by a;
131*c5c4113dSnw141292  }
132*c5c4113dSnw141292} {0 {}}
133*c5c4113dSnw141292do_test notnull-1.15 {
134*c5c4113dSnw141292  catchsql {
135*c5c4113dSnw141292    DELETE FROM t1;
136*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
137*c5c4113dSnw141292    SELECT * FROM t1 order by a;
138*c5c4113dSnw141292  }
139*c5c4113dSnw141292} {0 {1 2 6 4 5}}
140*c5c4113dSnw141292do_test notnull-1.16 {
141*c5c4113dSnw141292  catchsql {
142*c5c4113dSnw141292    DELETE FROM t1;
143*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
144*c5c4113dSnw141292    SELECT * FROM t1 order by a;
145*c5c4113dSnw141292  }
146*c5c4113dSnw141292} {1 {t1.c may not be NULL}}
147*c5c4113dSnw141292do_test notnull-1.17 {
148*c5c4113dSnw141292  catchsql {
149*c5c4113dSnw141292    DELETE FROM t1;
150*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
151*c5c4113dSnw141292    SELECT * FROM t1 order by a;
152*c5c4113dSnw141292  }
153*c5c4113dSnw141292} {1 {t1.d may not be NULL}}
154*c5c4113dSnw141292do_test notnull-1.18 {
155*c5c4113dSnw141292  catchsql {
156*c5c4113dSnw141292    DELETE FROM t1;
157*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
158*c5c4113dSnw141292    SELECT * FROM t1 order by a;
159*c5c4113dSnw141292  }
160*c5c4113dSnw141292} {0 {1 2 3 7 5}}
161*c5c4113dSnw141292do_test notnull-1.19 {
162*c5c4113dSnw141292  catchsql {
163*c5c4113dSnw141292    DELETE FROM t1;
164*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);
165*c5c4113dSnw141292    SELECT * FROM t1 order by a;
166*c5c4113dSnw141292  }
167*c5c4113dSnw141292} {0 {1 2 3 4 8}}
168*c5c4113dSnw141292do_test notnull-1.20 {
169*c5c4113dSnw141292  catchsql {
170*c5c4113dSnw141292    DELETE FROM t1;
171*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
172*c5c4113dSnw141292    SELECT * FROM t1 order by a;
173*c5c4113dSnw141292  }
174*c5c4113dSnw141292} {1 {t1.e may not be NULL}}
175*c5c4113dSnw141292do_test notnull-1.21 {
176*c5c4113dSnw141292  catchsql {
177*c5c4113dSnw141292    DELETE FROM t1;
178*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
179*c5c4113dSnw141292    SELECT * FROM t1 order by a;
180*c5c4113dSnw141292  }
181*c5c4113dSnw141292} {0 {5 5 3 2 1}}
182*c5c4113dSnw141292
183*c5c4113dSnw141292do_test notnull-2.1 {
184*c5c4113dSnw141292  catchsql {
185*c5c4113dSnw141292    DELETE FROM t1;
186*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
187*c5c4113dSnw141292    UPDATE t1 SET a=null;
188*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
189*c5c4113dSnw141292  }
190*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
191*c5c4113dSnw141292do_test notnull-2.2 {
192*c5c4113dSnw141292  catchsql {
193*c5c4113dSnw141292    DELETE FROM t1;
194*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
195*c5c4113dSnw141292    UPDATE OR REPLACE t1 SET a=null;
196*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
197*c5c4113dSnw141292  }
198*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
199*c5c4113dSnw141292do_test notnull-2.3 {
200*c5c4113dSnw141292  catchsql {
201*c5c4113dSnw141292    DELETE FROM t1;
202*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
203*c5c4113dSnw141292    UPDATE OR IGNORE t1 SET a=null;
204*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
205*c5c4113dSnw141292  }
206*c5c4113dSnw141292} {0 {1 2 3 4 5}}
207*c5c4113dSnw141292do_test notnull-2.4 {
208*c5c4113dSnw141292  catchsql {
209*c5c4113dSnw141292    DELETE FROM t1;
210*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
211*c5c4113dSnw141292    UPDATE OR ABORT t1 SET a=null;
212*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
213*c5c4113dSnw141292  }
214*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
215*c5c4113dSnw141292do_test notnull-2.5 {
216*c5c4113dSnw141292  catchsql {
217*c5c4113dSnw141292    DELETE FROM t1;
218*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
219*c5c4113dSnw141292    UPDATE t1 SET b=null;
220*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
221*c5c4113dSnw141292  }
222*c5c4113dSnw141292} {1 {t1.b may not be NULL}}
223*c5c4113dSnw141292do_test notnull-2.6 {
224*c5c4113dSnw141292  catchsql {
225*c5c4113dSnw141292    DELETE FROM t1;
226*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
227*c5c4113dSnw141292    UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
228*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
229*c5c4113dSnw141292  }
230*c5c4113dSnw141292} {0 {1 5 3 5 4}}
231*c5c4113dSnw141292do_test notnull-2.7 {
232*c5c4113dSnw141292  catchsql {
233*c5c4113dSnw141292    DELETE FROM t1;
234*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
235*c5c4113dSnw141292    UPDATE OR IGNORE t1 SET b=null, d=e, e=d;
236*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
237*c5c4113dSnw141292  }
238*c5c4113dSnw141292} {0 {1 2 3 4 5}}
239*c5c4113dSnw141292do_test notnull-2.8 {
240*c5c4113dSnw141292  catchsql {
241*c5c4113dSnw141292    DELETE FROM t1;
242*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
243*c5c4113dSnw141292    UPDATE t1 SET c=null, d=e, e=d;
244*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
245*c5c4113dSnw141292  }
246*c5c4113dSnw141292} {0 {1 2 6 5 4}}
247*c5c4113dSnw141292do_test notnull-2.9 {
248*c5c4113dSnw141292  catchsql {
249*c5c4113dSnw141292    DELETE FROM t1;
250*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
251*c5c4113dSnw141292    UPDATE t1 SET d=null, a=b, b=a;
252*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
253*c5c4113dSnw141292  }
254*c5c4113dSnw141292} {0 {1 2 3 4 5}}
255*c5c4113dSnw141292do_test notnull-2.10 {
256*c5c4113dSnw141292  catchsql {
257*c5c4113dSnw141292    DELETE FROM t1;
258*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
259*c5c4113dSnw141292    UPDATE t1 SET e=null, a=b, b=a;
260*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
261*c5c4113dSnw141292  }
262*c5c4113dSnw141292} {1 {t1.e may not be NULL}}
263*c5c4113dSnw141292
264*c5c4113dSnw141292do_test notnull-3.0 {
265*c5c4113dSnw141292  execsql {
266*c5c4113dSnw141292    CREATE INDEX t1a ON t1(a);
267*c5c4113dSnw141292    CREATE INDEX t1b ON t1(b);
268*c5c4113dSnw141292    CREATE INDEX t1c ON t1(c);
269*c5c4113dSnw141292    CREATE INDEX t1d ON t1(d);
270*c5c4113dSnw141292    CREATE INDEX t1e ON t1(e);
271*c5c4113dSnw141292    CREATE INDEX t1abc ON t1(a,b,c);
272*c5c4113dSnw141292  }
273*c5c4113dSnw141292} {}
274*c5c4113dSnw141292do_test notnull-3.1 {
275*c5c4113dSnw141292  catchsql {
276*c5c4113dSnw141292    DELETE FROM t1;
277*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);
278*c5c4113dSnw141292    SELECT * FROM t1 order by a;
279*c5c4113dSnw141292  }
280*c5c4113dSnw141292} {0 {1 2 3 4 5}}
281*c5c4113dSnw141292do_test notnull-3.2 {
282*c5c4113dSnw141292  catchsql {
283*c5c4113dSnw141292    DELETE FROM t1;
284*c5c4113dSnw141292    INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);
285*c5c4113dSnw141292    SELECT * FROM t1 order by a;
286*c5c4113dSnw141292  }
287*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
288*c5c4113dSnw141292do_test notnull-3.3 {
289*c5c4113dSnw141292  catchsql {
290*c5c4113dSnw141292    DELETE FROM t1;
291*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);
292*c5c4113dSnw141292    SELECT * FROM t1 order by a;
293*c5c4113dSnw141292  }
294*c5c4113dSnw141292} {0 {}}
295*c5c4113dSnw141292do_test notnull-3.4 {
296*c5c4113dSnw141292  catchsql {
297*c5c4113dSnw141292    DELETE FROM t1;
298*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);
299*c5c4113dSnw141292    SELECT * FROM t1 order by a;
300*c5c4113dSnw141292  }
301*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
302*c5c4113dSnw141292do_test notnull-3.5 {
303*c5c4113dSnw141292  catchsql {
304*c5c4113dSnw141292    DELETE FROM t1;
305*c5c4113dSnw141292    INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);
306*c5c4113dSnw141292    SELECT * FROM t1 order by a;
307*c5c4113dSnw141292  }
308*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
309*c5c4113dSnw141292do_test notnull-3.6 {
310*c5c4113dSnw141292  catchsql {
311*c5c4113dSnw141292    DELETE FROM t1;
312*c5c4113dSnw141292    INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);
313*c5c4113dSnw141292    SELECT * FROM t1 order by a;
314*c5c4113dSnw141292  }
315*c5c4113dSnw141292} {0 {1 5 3 4 5}}
316*c5c4113dSnw141292do_test notnull-3.7 {
317*c5c4113dSnw141292  catchsql {
318*c5c4113dSnw141292    DELETE FROM t1;
319*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);
320*c5c4113dSnw141292    SELECT * FROM t1 order by a;
321*c5c4113dSnw141292  }
322*c5c4113dSnw141292} {0 {1 5 3 4 5}}
323*c5c4113dSnw141292do_test notnull-3.8 {
324*c5c4113dSnw141292  catchsql {
325*c5c4113dSnw141292    DELETE FROM t1;
326*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);
327*c5c4113dSnw141292    SELECT * FROM t1 order by a;
328*c5c4113dSnw141292  }
329*c5c4113dSnw141292} {0 {1 5 3 4 5}}
330*c5c4113dSnw141292do_test notnull-3.9 {
331*c5c4113dSnw141292  catchsql {
332*c5c4113dSnw141292    DELETE FROM t1;
333*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);
334*c5c4113dSnw141292    SELECT * FROM t1 order by a;
335*c5c4113dSnw141292  }
336*c5c4113dSnw141292} {0 {1 5 3 4 5}}
337*c5c4113dSnw141292do_test notnull-3.10 {
338*c5c4113dSnw141292  catchsql {
339*c5c4113dSnw141292    DELETE FROM t1;
340*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
341*c5c4113dSnw141292    SELECT * FROM t1 order by a;
342*c5c4113dSnw141292  }
343*c5c4113dSnw141292} {1 {t1.b may not be NULL}}
344*c5c4113dSnw141292do_test notnull-3.11 {
345*c5c4113dSnw141292  catchsql {
346*c5c4113dSnw141292    DELETE FROM t1;
347*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
348*c5c4113dSnw141292    SELECT * FROM t1 order by a;
349*c5c4113dSnw141292  }
350*c5c4113dSnw141292} {0 {}}
351*c5c4113dSnw141292do_test notnull-3.12 {
352*c5c4113dSnw141292  catchsql {
353*c5c4113dSnw141292    DELETE FROM t1;
354*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);
355*c5c4113dSnw141292    SELECT * FROM t1 order by a;
356*c5c4113dSnw141292  }
357*c5c4113dSnw141292} {0 {1 5 3 4 5}}
358*c5c4113dSnw141292do_test notnull-3.13 {
359*c5c4113dSnw141292  catchsql {
360*c5c4113dSnw141292    DELETE FROM t1;
361*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
362*c5c4113dSnw141292    SELECT * FROM t1 order by a;
363*c5c4113dSnw141292  }
364*c5c4113dSnw141292} {0 {1 2 6 4 5}}
365*c5c4113dSnw141292do_test notnull-3.14 {
366*c5c4113dSnw141292  catchsql {
367*c5c4113dSnw141292    DELETE FROM t1;
368*c5c4113dSnw141292    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
369*c5c4113dSnw141292    SELECT * FROM t1 order by a;
370*c5c4113dSnw141292  }
371*c5c4113dSnw141292} {0 {}}
372*c5c4113dSnw141292do_test notnull-3.15 {
373*c5c4113dSnw141292  catchsql {
374*c5c4113dSnw141292    DELETE FROM t1;
375*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
376*c5c4113dSnw141292    SELECT * FROM t1 order by a;
377*c5c4113dSnw141292  }
378*c5c4113dSnw141292} {0 {1 2 6 4 5}}
379*c5c4113dSnw141292do_test notnull-3.16 {
380*c5c4113dSnw141292  catchsql {
381*c5c4113dSnw141292    DELETE FROM t1;
382*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);
383*c5c4113dSnw141292    SELECT * FROM t1 order by a;
384*c5c4113dSnw141292  }
385*c5c4113dSnw141292} {1 {t1.c may not be NULL}}
386*c5c4113dSnw141292do_test notnull-3.17 {
387*c5c4113dSnw141292  catchsql {
388*c5c4113dSnw141292    DELETE FROM t1;
389*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);
390*c5c4113dSnw141292    SELECT * FROM t1 order by a;
391*c5c4113dSnw141292  }
392*c5c4113dSnw141292} {1 {t1.d may not be NULL}}
393*c5c4113dSnw141292do_test notnull-3.18 {
394*c5c4113dSnw141292  catchsql {
395*c5c4113dSnw141292    DELETE FROM t1;
396*c5c4113dSnw141292    INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);
397*c5c4113dSnw141292    SELECT * FROM t1 order by a;
398*c5c4113dSnw141292  }
399*c5c4113dSnw141292} {0 {1 2 3 7 5}}
400*c5c4113dSnw141292do_test notnull-3.19 {
401*c5c4113dSnw141292  catchsql {
402*c5c4113dSnw141292    DELETE FROM t1;
403*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);
404*c5c4113dSnw141292    SELECT * FROM t1 order by a;
405*c5c4113dSnw141292  }
406*c5c4113dSnw141292} {0 {1 2 3 4 8}}
407*c5c4113dSnw141292do_test notnull-3.20 {
408*c5c4113dSnw141292  catchsql {
409*c5c4113dSnw141292    DELETE FROM t1;
410*c5c4113dSnw141292    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);
411*c5c4113dSnw141292    SELECT * FROM t1 order by a;
412*c5c4113dSnw141292  }
413*c5c4113dSnw141292} {1 {t1.e may not be NULL}}
414*c5c4113dSnw141292do_test notnull-3.21 {
415*c5c4113dSnw141292  catchsql {
416*c5c4113dSnw141292    DELETE FROM t1;
417*c5c4113dSnw141292    INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);
418*c5c4113dSnw141292    SELECT * FROM t1 order by a;
419*c5c4113dSnw141292  }
420*c5c4113dSnw141292} {0 {5 5 3 2 1}}
421*c5c4113dSnw141292
422*c5c4113dSnw141292do_test notnull-4.1 {
423*c5c4113dSnw141292  catchsql {
424*c5c4113dSnw141292    DELETE FROM t1;
425*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
426*c5c4113dSnw141292    UPDATE t1 SET a=null;
427*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
428*c5c4113dSnw141292  }
429*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
430*c5c4113dSnw141292do_test notnull-4.2 {
431*c5c4113dSnw141292  catchsql {
432*c5c4113dSnw141292    DELETE FROM t1;
433*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
434*c5c4113dSnw141292    UPDATE OR REPLACE t1 SET a=null;
435*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
436*c5c4113dSnw141292  }
437*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
438*c5c4113dSnw141292do_test notnull-4.3 {
439*c5c4113dSnw141292  catchsql {
440*c5c4113dSnw141292    DELETE FROM t1;
441*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
442*c5c4113dSnw141292    UPDATE OR IGNORE t1 SET a=null;
443*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
444*c5c4113dSnw141292  }
445*c5c4113dSnw141292} {0 {1 2 3 4 5}}
446*c5c4113dSnw141292do_test notnull-4.4 {
447*c5c4113dSnw141292  catchsql {
448*c5c4113dSnw141292    DELETE FROM t1;
449*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
450*c5c4113dSnw141292    UPDATE OR ABORT t1 SET a=null;
451*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
452*c5c4113dSnw141292  }
453*c5c4113dSnw141292} {1 {t1.a may not be NULL}}
454*c5c4113dSnw141292do_test notnull-4.5 {
455*c5c4113dSnw141292  catchsql {
456*c5c4113dSnw141292    DELETE FROM t1;
457*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
458*c5c4113dSnw141292    UPDATE t1 SET b=null;
459*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
460*c5c4113dSnw141292  }
461*c5c4113dSnw141292} {1 {t1.b may not be NULL}}
462*c5c4113dSnw141292do_test notnull-4.6 {
463*c5c4113dSnw141292  catchsql {
464*c5c4113dSnw141292    DELETE FROM t1;
465*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
466*c5c4113dSnw141292    UPDATE OR REPLACE t1 SET b=null, d=e, e=d;
467*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
468*c5c4113dSnw141292  }
469*c5c4113dSnw141292} {0 {1 5 3 5 4}}
470*c5c4113dSnw141292do_test notnull-4.7 {
471*c5c4113dSnw141292  catchsql {
472*c5c4113dSnw141292    DELETE FROM t1;
473*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
474*c5c4113dSnw141292    UPDATE OR IGNORE t1 SET b=null, d=e, e=d;
475*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
476*c5c4113dSnw141292  }
477*c5c4113dSnw141292} {0 {1 2 3 4 5}}
478*c5c4113dSnw141292do_test notnull-4.8 {
479*c5c4113dSnw141292  catchsql {
480*c5c4113dSnw141292    DELETE FROM t1;
481*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
482*c5c4113dSnw141292    UPDATE t1 SET c=null, d=e, e=d;
483*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
484*c5c4113dSnw141292  }
485*c5c4113dSnw141292} {0 {1 2 6 5 4}}
486*c5c4113dSnw141292do_test notnull-4.9 {
487*c5c4113dSnw141292  catchsql {
488*c5c4113dSnw141292    DELETE FROM t1;
489*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
490*c5c4113dSnw141292    UPDATE t1 SET d=null, a=b, b=a;
491*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
492*c5c4113dSnw141292  }
493*c5c4113dSnw141292} {0 {1 2 3 4 5}}
494*c5c4113dSnw141292do_test notnull-4.10 {
495*c5c4113dSnw141292  catchsql {
496*c5c4113dSnw141292    DELETE FROM t1;
497*c5c4113dSnw141292    INSERT INTO t1 VALUES(1,2,3,4,5);
498*c5c4113dSnw141292    UPDATE t1 SET e=null, a=b, b=a;
499*c5c4113dSnw141292    SELECT * FROM t1 ORDER BY a;
500*c5c4113dSnw141292  }
501*c5c4113dSnw141292} {1 {t1.e may not be NULL}}
502*c5c4113dSnw141292
503*c5c4113dSnw141292finish_test
504