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