os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/where5.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
# 2007 June 8
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.  The
sl@0
    12
# focus of this file is testing NULL comparisons in the WHERE clause.
sl@0
    13
# See ticket #2404.
sl@0
    14
#
sl@0
    15
# $Id: where5.test,v 1.2 2007/06/08 08:43:10 drh 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
# Build some test data
sl@0
    21
#
sl@0
    22
do_test where5-1.0 {
sl@0
    23
  execsql {
sl@0
    24
    CREATE TABLE t1(x TEXT);
sl@0
    25
    CREATE TABLE t2(x INTEGER);
sl@0
    26
    CREATE TABLE t3(x INTEGER PRIMARY KEY);
sl@0
    27
    INSERT INTO t1 VALUES(-1);
sl@0
    28
    INSERT INTO t1 VALUES(0);
sl@0
    29
    INSERT INTO t1 VALUES(1);
sl@0
    30
    INSERT INTO t2 SELECT * FROM t1;
sl@0
    31
    INSERT INTO t3 SELECT * FROM t2;
sl@0
    32
  }
sl@0
    33
  execsql {
sl@0
    34
    SELECT * FROM t1 WHERE x<0
sl@0
    35
  }
sl@0
    36
} {-1}
sl@0
    37
do_test where5-1.1 {
sl@0
    38
  execsql {
sl@0
    39
    SELECT * FROM t1 WHERE x<=0
sl@0
    40
  }
sl@0
    41
} {-1 0}
sl@0
    42
do_test where5-1.2 {
sl@0
    43
  execsql {
sl@0
    44
    SELECT * FROM t1 WHERE x=0
sl@0
    45
  }
sl@0
    46
} {0}
sl@0
    47
do_test where5-1.3 {
sl@0
    48
  execsql {
sl@0
    49
    SELECT * FROM t1 WHERE x>=0
sl@0
    50
  }
sl@0
    51
} {0 1}
sl@0
    52
do_test where5-1.4 {
sl@0
    53
  execsql {
sl@0
    54
    SELECT * FROM t1 WHERE x>0
sl@0
    55
  }
sl@0
    56
} {1}
sl@0
    57
do_test where5-1.5 {
sl@0
    58
  execsql {
sl@0
    59
    SELECT * FROM t1 WHERE x<>0
sl@0
    60
  }
sl@0
    61
} {-1 1}
sl@0
    62
do_test where5-1.6 {
sl@0
    63
  execsql {
sl@0
    64
    SELECT * FROM t1 WHERE x<NULL
sl@0
    65
  }
sl@0
    66
} {}
sl@0
    67
do_test where5-1.7 {
sl@0
    68
  execsql {
sl@0
    69
    SELECT * FROM t1 WHERE x<=NULL
sl@0
    70
  }
sl@0
    71
} {}
sl@0
    72
do_test where5-1.8 {
sl@0
    73
  execsql {
sl@0
    74
    SELECT * FROM t1 WHERE x=NULL
sl@0
    75
  }
sl@0
    76
} {}
sl@0
    77
do_test where5-1.9 {
sl@0
    78
  execsql {
sl@0
    79
    SELECT * FROM t1 WHERE x>=NULL
sl@0
    80
  }
sl@0
    81
} {}
sl@0
    82
do_test where5-1.10 {
sl@0
    83
  execsql {
sl@0
    84
    SELECT * FROM t1 WHERE x>NULL
sl@0
    85
  }
sl@0
    86
} {}
sl@0
    87
do_test where5-1.11 {
sl@0
    88
  execsql {
sl@0
    89
    SELECT * FROM t1 WHERE x!=NULL
sl@0
    90
  }
sl@0
    91
} {}
sl@0
    92
do_test where5-1.12 {
sl@0
    93
  execsql {
sl@0
    94
    SELECT * FROM t1 WHERE x IS NULL
sl@0
    95
  }
sl@0
    96
} {}
sl@0
    97
do_test where5-1.13 {
sl@0
    98
  execsql {
sl@0
    99
    SELECT * FROM t1 WHERE x IS NOT NULL
sl@0
   100
  }
sl@0
   101
} {-1 0 1}
sl@0
   102
sl@0
   103
sl@0
   104
do_test where5-2.0 {
sl@0
   105
  execsql {
sl@0
   106
    SELECT * FROM t2 WHERE x<0
sl@0
   107
  }
sl@0
   108
} {-1}
sl@0
   109
do_test where5-2.1 {
sl@0
   110
  execsql {
sl@0
   111
    SELECT * FROM t2 WHERE x<=0
sl@0
   112
  }
sl@0
   113
} {-1 0}
sl@0
   114
do_test where5-2.2 {
sl@0
   115
  execsql {
sl@0
   116
    SELECT * FROM t2 WHERE x=0
sl@0
   117
  }
sl@0
   118
} {0}
sl@0
   119
do_test where5-2.3 {
sl@0
   120
  execsql {
sl@0
   121
    SELECT * FROM t2 WHERE x>=0
sl@0
   122
  }
sl@0
   123
} {0 1}
sl@0
   124
do_test where5-2.4 {
sl@0
   125
  execsql {
sl@0
   126
    SELECT * FROM t2 WHERE x>0
sl@0
   127
  }
sl@0
   128
} {1}
sl@0
   129
do_test where5-2.5 {
sl@0
   130
  execsql {
sl@0
   131
    SELECT * FROM t2 WHERE x<>0
sl@0
   132
  }
sl@0
   133
} {-1 1}
sl@0
   134
do_test where5-2.6 {
sl@0
   135
  execsql {
sl@0
   136
    SELECT * FROM t2 WHERE x<NULL
sl@0
   137
  }
sl@0
   138
} {}
sl@0
   139
do_test where5-2.7 {
sl@0
   140
  execsql {
sl@0
   141
    SELECT * FROM t2 WHERE x<=NULL
sl@0
   142
  }
sl@0
   143
} {}
sl@0
   144
do_test where5-2.8 {
sl@0
   145
  execsql {
sl@0
   146
    SELECT * FROM t2 WHERE x=NULL
sl@0
   147
  }
sl@0
   148
} {}
sl@0
   149
do_test where5-2.9 {
sl@0
   150
  execsql {
sl@0
   151
    SELECT * FROM t2 WHERE x>=NULL
sl@0
   152
  }
sl@0
   153
} {}
sl@0
   154
do_test where5-2.10 {
sl@0
   155
  execsql {
sl@0
   156
    SELECT * FROM t2 WHERE x>NULL
sl@0
   157
  }
sl@0
   158
} {}
sl@0
   159
do_test where5-2.11 {
sl@0
   160
  execsql {
sl@0
   161
    SELECT * FROM t2 WHERE x!=NULL
sl@0
   162
  }
sl@0
   163
} {}
sl@0
   164
do_test where5-2.12 {
sl@0
   165
  execsql {
sl@0
   166
    SELECT * FROM t2 WHERE x IS NULL
sl@0
   167
  }
sl@0
   168
} {}
sl@0
   169
do_test where5-2.13 {
sl@0
   170
  execsql {
sl@0
   171
    SELECT * FROM t2 WHERE x IS NOT NULL
sl@0
   172
  }
sl@0
   173
} {-1 0 1}
sl@0
   174
sl@0
   175
sl@0
   176
do_test where5-3.0 {
sl@0
   177
  execsql {
sl@0
   178
    SELECT * FROM t3 WHERE x<0
sl@0
   179
  }
sl@0
   180
} {-1}
sl@0
   181
do_test where5-3.1 {
sl@0
   182
  execsql {
sl@0
   183
    SELECT * FROM t3 WHERE x<=0
sl@0
   184
  }
sl@0
   185
} {-1 0}
sl@0
   186
do_test where5-3.2 {
sl@0
   187
  execsql {
sl@0
   188
    SELECT * FROM t3 WHERE x=0
sl@0
   189
  }
sl@0
   190
} {0}
sl@0
   191
do_test where5-3.3 {
sl@0
   192
  execsql {
sl@0
   193
    SELECT * FROM t3 WHERE x>=0
sl@0
   194
  }
sl@0
   195
} {0 1}
sl@0
   196
do_test where5-3.4 {
sl@0
   197
  execsql {
sl@0
   198
    SELECT * FROM t3 WHERE x>0
sl@0
   199
  }
sl@0
   200
} {1}
sl@0
   201
do_test where5-3.5 {
sl@0
   202
  execsql {
sl@0
   203
    SELECT * FROM t3 WHERE x<>0
sl@0
   204
  }
sl@0
   205
} {-1 1}
sl@0
   206
do_test where5-3.6 {
sl@0
   207
  execsql {
sl@0
   208
    SELECT * FROM t3 WHERE x<NULL
sl@0
   209
  }
sl@0
   210
} {}
sl@0
   211
do_test where5-3.7 {
sl@0
   212
  execsql {
sl@0
   213
    SELECT * FROM t3 WHERE x<=NULL
sl@0
   214
  }
sl@0
   215
} {}
sl@0
   216
do_test where5-3.8 {
sl@0
   217
  execsql {
sl@0
   218
    SELECT * FROM t3 WHERE x=NULL
sl@0
   219
  }
sl@0
   220
} {}
sl@0
   221
do_test where5-3.9 {
sl@0
   222
  execsql {
sl@0
   223
    SELECT * FROM t3 WHERE x>=NULL
sl@0
   224
  }
sl@0
   225
} {}
sl@0
   226
do_test where5-3.10 {
sl@0
   227
  execsql {
sl@0
   228
    SELECT * FROM t3 WHERE x>NULL
sl@0
   229
  }
sl@0
   230
} {}
sl@0
   231
do_test where5-3.11 {
sl@0
   232
  execsql {
sl@0
   233
    SELECT * FROM t3 WHERE x!=NULL
sl@0
   234
  }
sl@0
   235
} {}
sl@0
   236
do_test where5-3.12 {
sl@0
   237
  execsql {
sl@0
   238
    SELECT * FROM t3 WHERE x IS NULL
sl@0
   239
  }
sl@0
   240
} {}
sl@0
   241
do_test where5-3.13 {
sl@0
   242
  execsql {
sl@0
   243
    SELECT * FROM t3 WHERE x IS NOT NULL
sl@0
   244
  }
sl@0
   245
} {-1 0 1}
sl@0
   246
sl@0
   247
do_test where5-4.0 {
sl@0
   248
  execsql {
sl@0
   249
    SELECT x<NULL FROM t3
sl@0
   250
  }
sl@0
   251
} {{} {} {}}
sl@0
   252
do_test where5-4.1 {
sl@0
   253
  execsql {
sl@0
   254
    SELECT x<=NULL FROM t3
sl@0
   255
  }
sl@0
   256
} {{} {} {}}
sl@0
   257
do_test where5-4.2 {
sl@0
   258
  execsql {
sl@0
   259
    SELECT x==NULL FROM t3
sl@0
   260
  }
sl@0
   261
} {{} {} {}}
sl@0
   262
do_test where5-4.3 {
sl@0
   263
  execsql {
sl@0
   264
    SELECT x>NULL FROM t3
sl@0
   265
  }
sl@0
   266
} {{} {} {}}
sl@0
   267
do_test where5-4.4 {
sl@0
   268
  execsql {
sl@0
   269
    SELECT x>=NULL FROM t3
sl@0
   270
  }
sl@0
   271
} {{} {} {}}
sl@0
   272
do_test where5-4.5 {
sl@0
   273
  execsql {
sl@0
   274
    SELECT x!=NULL FROM t3
sl@0
   275
  }
sl@0
   276
} {{} {} {}}
sl@0
   277
do_test where5-4.6 {
sl@0
   278
  execsql {
sl@0
   279
    SELECT x IS NULL FROM t3
sl@0
   280
  }
sl@0
   281
} {0 0 0}
sl@0
   282
do_test where5-4.7 {
sl@0
   283
  execsql {
sl@0
   284
    SELECT x IS NOT NULL FROM t3
sl@0
   285
  }
sl@0
   286
} {1 1 1}
sl@0
   287
sl@0
   288
finish_test