os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt1473.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
# 2005 September 19
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 to verify that ticket #1473 has been
sl@0
    14
# fixed.  
sl@0
    15
#
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 !compound {
sl@0
    21
  finish_test
sl@0
    22
  return 
sl@0
    23
}
sl@0
    24
sl@0
    25
do_test tkt1473-1.1 {
sl@0
    26
  execsql {
sl@0
    27
    CREATE TABLE t1(a,b);
sl@0
    28
    INSERT INTO t1 VALUES(1,2);
sl@0
    29
    INSERT INTO t1 VALUES(3,4);
sl@0
    30
    SELECT * FROM t1
sl@0
    31
  }
sl@0
    32
} {1 2 3 4}
sl@0
    33
sl@0
    34
do_test tkt1473-1.2 {
sl@0
    35
  execsql {
sl@0
    36
    SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0
sl@0
    37
  }
sl@0
    38
} {1}
sl@0
    39
do_test tkt1473-1.3 {
sl@0
    40
  execsql {
sl@0
    41
    SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0
sl@0
    42
  }
sl@0
    43
} {1}
sl@0
    44
do_test tkt1473-1.4 {
sl@0
    45
  execsql {
sl@0
    46
    SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4
sl@0
    47
  }
sl@0
    48
} {1 2}
sl@0
    49
do_test tkt1473-1.5 {
sl@0
    50
  execsql {
sl@0
    51
    SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4
sl@0
    52
  }
sl@0
    53
} {1 2}
sl@0
    54
do_test tkt1473-1.6 {
sl@0
    55
  execsql {
sl@0
    56
    SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4
sl@0
    57
  }
sl@0
    58
} {2}
sl@0
    59
do_test tkt1473-1.7 {
sl@0
    60
  execsql {
sl@0
    61
    SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4
sl@0
    62
  }
sl@0
    63
} {2}
sl@0
    64
do_test tkt1473-1.8 {
sl@0
    65
  execsql {
sl@0
    66
    SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0
sl@0
    67
  }
sl@0
    68
} {}
sl@0
    69
do_test tkt1473-1.9 {
sl@0
    70
  execsql {
sl@0
    71
    SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0
sl@0
    72
  }
sl@0
    73
} {}
sl@0
    74
sl@0
    75
# Everything from this point on depends on sub-queries. So skip it
sl@0
    76
# if sub-queries are not available.
sl@0
    77
ifcapable !subquery {
sl@0
    78
  finish_test
sl@0
    79
  return
sl@0
    80
}
sl@0
    81
sl@0
    82
do_test tkt1473-2.2 {
sl@0
    83
  execsql {
sl@0
    84
    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)
sl@0
    85
  }
sl@0
    86
} {1}
sl@0
    87
do_test tkt1473-2.3 {
sl@0
    88
  execsql {
sl@0
    89
    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)
sl@0
    90
  }
sl@0
    91
} {1}
sl@0
    92
do_test tkt1473-2.4 {
sl@0
    93
  execsql {
sl@0
    94
    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)
sl@0
    95
  }
sl@0
    96
} {1}
sl@0
    97
do_test tkt1473-2.5 {
sl@0
    98
  execsql {
sl@0
    99
    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)
sl@0
   100
  }
sl@0
   101
} {1}
sl@0
   102
do_test tkt1473-2.6 {
sl@0
   103
  execsql {
sl@0
   104
    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)
sl@0
   105
  }
sl@0
   106
} {2}
sl@0
   107
do_test tkt1473-2.7 {
sl@0
   108
  execsql {
sl@0
   109
    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)
sl@0
   110
  }
sl@0
   111
} {2}
sl@0
   112
do_test tkt1473-2.8 {
sl@0
   113
  execsql {
sl@0
   114
    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)
sl@0
   115
  }
sl@0
   116
} {{}}
sl@0
   117
do_test tkt1473-2.9 {
sl@0
   118
  execsql {
sl@0
   119
    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)
sl@0
   120
  }
sl@0
   121
} {{}}
sl@0
   122
sl@0
   123
do_test tkt1473-3.2 {
sl@0
   124
  execsql {
sl@0
   125
    SELECT EXISTS
sl@0
   126
      (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)
sl@0
   127
  }
sl@0
   128
} {1}
sl@0
   129
do_test tkt1473-3.3 {
sl@0
   130
  execsql {
sl@0
   131
    SELECT EXISTS
sl@0
   132
      (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)
sl@0
   133
  }
sl@0
   134
} {1}
sl@0
   135
do_test tkt1473-3.4 {
sl@0
   136
  execsql {
sl@0
   137
    SELECT EXISTS
sl@0
   138
      (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)
sl@0
   139
  }
sl@0
   140
} {1}
sl@0
   141
do_test tkt1473-3.5 {
sl@0
   142
  execsql {
sl@0
   143
    SELECT EXISTS
sl@0
   144
      (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)
sl@0
   145
  }
sl@0
   146
} {1}
sl@0
   147
do_test tkt1473-3.6 {
sl@0
   148
  execsql {
sl@0
   149
    SELECT EXISTS
sl@0
   150
      (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)
sl@0
   151
  }
sl@0
   152
} {1}
sl@0
   153
do_test tkt1473-3.7 {
sl@0
   154
  execsql {
sl@0
   155
    SELECT EXISTS
sl@0
   156
      (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)
sl@0
   157
  }
sl@0
   158
} {1}
sl@0
   159
do_test tkt1473-3.8 {
sl@0
   160
  execsql {
sl@0
   161
    SELECT EXISTS
sl@0
   162
      (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)
sl@0
   163
  }
sl@0
   164
} {0}
sl@0
   165
do_test tkt1473-3.9 {
sl@0
   166
  execsql {
sl@0
   167
    SELECT EXISTS
sl@0
   168
      (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)
sl@0
   169
  }
sl@0
   170
} {0}
sl@0
   171
sl@0
   172
do_test tkt1473-4.1 {
sl@0
   173
  execsql {
sl@0
   174
    CREATE TABLE t2(x,y);
sl@0
   175
    INSERT INTO t2 VALUES(1,2);
sl@0
   176
    INSERT INTO t2 SELECT x+2, y+2 FROM t2;
sl@0
   177
    INSERT INTO t2 SELECT x+4, y+4 FROM t2;
sl@0
   178
    INSERT INTO t2 SELECT x+8, y+8 FROM t2;
sl@0
   179
    INSERT INTO t2 SELECT x+16, y+16 FROM t2;
sl@0
   180
    INSERT INTO t2 SELECT x+32, y+32 FROM t2;
sl@0
   181
    INSERT INTO t2 SELECT x+64, y+64 FROM t2;
sl@0
   182
    SELECT count(*), sum(x), sum(y) FROM t2;
sl@0
   183
  }
sl@0
   184
} {64 4096 4160}
sl@0
   185
do_test tkt1473-4.2 {
sl@0
   186
  execsql {
sl@0
   187
    SELECT 1 FROM t2 WHERE x=0
sl@0
   188
    UNION ALL
sl@0
   189
    SELECT 2 FROM t2 WHERE x=1
sl@0
   190
    UNION ALL
sl@0
   191
    SELECT 3 FROM t2 WHERE x=2
sl@0
   192
    UNION ALL
sl@0
   193
    SELECT 4 FROM t2 WHERE x=3
sl@0
   194
    UNION ALL
sl@0
   195
    SELECT 5 FROM t2 WHERE x=4
sl@0
   196
    UNION ALL
sl@0
   197
    SELECT 6 FROM t2 WHERE y=0
sl@0
   198
    UNION ALL
sl@0
   199
    SELECT 7 FROM t2 WHERE y=1
sl@0
   200
    UNION ALL
sl@0
   201
    SELECT 8 FROM t2 WHERE y=2
sl@0
   202
    UNION ALL
sl@0
   203
    SELECT 9 FROM t2 WHERE y=3
sl@0
   204
    UNION ALL
sl@0
   205
    SELECT 10 FROM t2 WHERE y=4
sl@0
   206
  }
sl@0
   207
} {2 4 8 10}
sl@0
   208
do_test tkt1473-4.3 {
sl@0
   209
  execsql {
sl@0
   210
    SELECT (
sl@0
   211
      SELECT 1 FROM t2 WHERE x=0
sl@0
   212
      UNION ALL
sl@0
   213
      SELECT 2 FROM t2 WHERE x=1
sl@0
   214
      UNION ALL
sl@0
   215
      SELECT 3 FROM t2 WHERE x=2
sl@0
   216
      UNION ALL
sl@0
   217
      SELECT 4 FROM t2 WHERE x=3
sl@0
   218
      UNION ALL
sl@0
   219
      SELECT 5 FROM t2 WHERE x=4
sl@0
   220
      UNION ALL
sl@0
   221
      SELECT 6 FROM t2 WHERE y=0
sl@0
   222
      UNION ALL
sl@0
   223
      SELECT 7 FROM t2 WHERE y=1
sl@0
   224
      UNION ALL
sl@0
   225
      SELECT 8 FROM t2 WHERE y=2
sl@0
   226
      UNION ALL
sl@0
   227
      SELECT 9 FROM t2 WHERE y=3
sl@0
   228
      UNION ALL
sl@0
   229
      SELECT 10 FROM t2 WHERE y=4
sl@0
   230
    )
sl@0
   231
  }
sl@0
   232
} {2}
sl@0
   233
do_test tkt1473-4.4 {
sl@0
   234
  execsql {
sl@0
   235
    SELECT (
sl@0
   236
      SELECT 1 FROM t2 WHERE x=0
sl@0
   237
      UNION ALL
sl@0
   238
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   239
      UNION ALL
sl@0
   240
      SELECT 3 FROM t2 WHERE x=2
sl@0
   241
      UNION ALL
sl@0
   242
      SELECT 4 FROM t2 WHERE x=3
sl@0
   243
      UNION ALL
sl@0
   244
      SELECT 5 FROM t2 WHERE x=4
sl@0
   245
      UNION ALL
sl@0
   246
      SELECT 6 FROM t2 WHERE y=0
sl@0
   247
      UNION ALL
sl@0
   248
      SELECT 7 FROM t2 WHERE y=1
sl@0
   249
      UNION ALL
sl@0
   250
      SELECT 8 FROM t2 WHERE y=2
sl@0
   251
      UNION ALL
sl@0
   252
      SELECT 9 FROM t2 WHERE y=3
sl@0
   253
      UNION ALL
sl@0
   254
      SELECT 10 FROM t2 WHERE y=4
sl@0
   255
    )
sl@0
   256
  }
sl@0
   257
} {4}
sl@0
   258
do_test tkt1473-4.5 {
sl@0
   259
  execsql {
sl@0
   260
    SELECT (
sl@0
   261
      SELECT 1 FROM t2 WHERE x=0
sl@0
   262
      UNION ALL
sl@0
   263
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   264
      UNION ALL
sl@0
   265
      SELECT 3 FROM t2 WHERE x=2
sl@0
   266
      UNION ALL
sl@0
   267
      SELECT 4 FROM t2 WHERE x=-1
sl@0
   268
      UNION ALL
sl@0
   269
      SELECT 5 FROM t2 WHERE x=4
sl@0
   270
      UNION ALL
sl@0
   271
      SELECT 6 FROM t2 WHERE y=0
sl@0
   272
      UNION ALL
sl@0
   273
      SELECT 7 FROM t2 WHERE y=1
sl@0
   274
      UNION ALL
sl@0
   275
      SELECT 8 FROM t2 WHERE y=2
sl@0
   276
      UNION ALL
sl@0
   277
      SELECT 9 FROM t2 WHERE y=3
sl@0
   278
      UNION ALL
sl@0
   279
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   280
    )
sl@0
   281
  }
sl@0
   282
} {8}
sl@0
   283
do_test tkt1473-4.6 {
sl@0
   284
  execsql {
sl@0
   285
    SELECT (
sl@0
   286
      SELECT 1 FROM t2 WHERE x=0
sl@0
   287
      UNION ALL
sl@0
   288
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   289
      UNION ALL
sl@0
   290
      SELECT 3 FROM t2 WHERE x=2
sl@0
   291
      UNION ALL
sl@0
   292
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   293
      UNION ALL
sl@0
   294
      SELECT 5 FROM t2 WHERE x=4
sl@0
   295
      UNION ALL
sl@0
   296
      SELECT 6 FROM t2 WHERE y=0
sl@0
   297
      UNION ALL
sl@0
   298
      SELECT 7 FROM t2 WHERE y=1
sl@0
   299
      UNION ALL
sl@0
   300
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   301
      UNION ALL
sl@0
   302
      SELECT 9 FROM t2 WHERE y=3
sl@0
   303
      UNION ALL
sl@0
   304
      SELECT 10 FROM t2 WHERE y=4
sl@0
   305
    )
sl@0
   306
  }
sl@0
   307
} {10}
sl@0
   308
do_test tkt1473-4.7 {
sl@0
   309
  execsql {
sl@0
   310
    SELECT (
sl@0
   311
      SELECT 1 FROM t2 WHERE x=0
sl@0
   312
      UNION ALL
sl@0
   313
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   314
      UNION ALL
sl@0
   315
      SELECT 3 FROM t2 WHERE x=2
sl@0
   316
      UNION ALL
sl@0
   317
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   318
      UNION ALL
sl@0
   319
      SELECT 5 FROM t2 WHERE x=4
sl@0
   320
      UNION ALL
sl@0
   321
      SELECT 6 FROM t2 WHERE y=0
sl@0
   322
      UNION ALL
sl@0
   323
      SELECT 7 FROM t2 WHERE y=1
sl@0
   324
      UNION ALL
sl@0
   325
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   326
      UNION ALL
sl@0
   327
      SELECT 9 FROM t2 WHERE y=3
sl@0
   328
      UNION ALL
sl@0
   329
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   330
    )
sl@0
   331
  }
sl@0
   332
} {{}}
sl@0
   333
sl@0
   334
do_test tkt1473-5.3 {
sl@0
   335
  execsql {
sl@0
   336
    SELECT EXISTS (
sl@0
   337
      SELECT 1 FROM t2 WHERE x=0
sl@0
   338
      UNION ALL
sl@0
   339
      SELECT 2 FROM t2 WHERE x=1
sl@0
   340
      UNION ALL
sl@0
   341
      SELECT 3 FROM t2 WHERE x=2
sl@0
   342
      UNION ALL
sl@0
   343
      SELECT 4 FROM t2 WHERE x=3
sl@0
   344
      UNION ALL
sl@0
   345
      SELECT 5 FROM t2 WHERE x=4
sl@0
   346
      UNION ALL
sl@0
   347
      SELECT 6 FROM t2 WHERE y=0
sl@0
   348
      UNION ALL
sl@0
   349
      SELECT 7 FROM t2 WHERE y=1
sl@0
   350
      UNION ALL
sl@0
   351
      SELECT 8 FROM t2 WHERE y=2
sl@0
   352
      UNION ALL
sl@0
   353
      SELECT 9 FROM t2 WHERE y=3
sl@0
   354
      UNION ALL
sl@0
   355
      SELECT 10 FROM t2 WHERE y=4
sl@0
   356
    )
sl@0
   357
  }
sl@0
   358
} {1}
sl@0
   359
do_test tkt1473-5.4 {
sl@0
   360
  execsql {
sl@0
   361
    SELECT EXISTS (
sl@0
   362
      SELECT 1 FROM t2 WHERE x=0
sl@0
   363
      UNION ALL
sl@0
   364
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   365
      UNION ALL
sl@0
   366
      SELECT 3 FROM t2 WHERE x=2
sl@0
   367
      UNION ALL
sl@0
   368
      SELECT 4 FROM t2 WHERE x=3
sl@0
   369
      UNION ALL
sl@0
   370
      SELECT 5 FROM t2 WHERE x=4
sl@0
   371
      UNION ALL
sl@0
   372
      SELECT 6 FROM t2 WHERE y=0
sl@0
   373
      UNION ALL
sl@0
   374
      SELECT 7 FROM t2 WHERE y=1
sl@0
   375
      UNION ALL
sl@0
   376
      SELECT 8 FROM t2 WHERE y=2
sl@0
   377
      UNION ALL
sl@0
   378
      SELECT 9 FROM t2 WHERE y=3
sl@0
   379
      UNION ALL
sl@0
   380
      SELECT 10 FROM t2 WHERE y=4
sl@0
   381
    )
sl@0
   382
  }
sl@0
   383
} {1}
sl@0
   384
sl@0
   385
do_test tkt1473-5.5 {
sl@0
   386
  execsql {
sl@0
   387
    SELECT EXISTS (
sl@0
   388
      SELECT 1 FROM t2 WHERE x=0
sl@0
   389
      UNION ALL
sl@0
   390
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   391
      UNION ALL
sl@0
   392
      SELECT 3 FROM t2 WHERE x=2
sl@0
   393
      UNION ALL
sl@0
   394
      SELECT 4 FROM t2 WHERE x=-1
sl@0
   395
      UNION ALL
sl@0
   396
      SELECT 5 FROM t2 WHERE x=4
sl@0
   397
      UNION ALL
sl@0
   398
      SELECT 6 FROM t2 WHERE y=0
sl@0
   399
      UNION ALL
sl@0
   400
      SELECT 7 FROM t2 WHERE y=1
sl@0
   401
      UNION ALL
sl@0
   402
      SELECT 8 FROM t2 WHERE y=2
sl@0
   403
      UNION ALL
sl@0
   404
      SELECT 9 FROM t2 WHERE y=3
sl@0
   405
      UNION ALL
sl@0
   406
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   407
    )
sl@0
   408
  }
sl@0
   409
} {1}
sl@0
   410
do_test tkt1473-5.6 {
sl@0
   411
  execsql {
sl@0
   412
    SELECT EXISTS (
sl@0
   413
      SELECT 1 FROM t2 WHERE x=0
sl@0
   414
      UNION ALL
sl@0
   415
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   416
      UNION ALL
sl@0
   417
      SELECT 3 FROM t2 WHERE x=2
sl@0
   418
      UNION ALL
sl@0
   419
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   420
      UNION ALL
sl@0
   421
      SELECT 5 FROM t2 WHERE x=4
sl@0
   422
      UNION ALL
sl@0
   423
      SELECT 6 FROM t2 WHERE y=0
sl@0
   424
      UNION ALL
sl@0
   425
      SELECT 7 FROM t2 WHERE y=1
sl@0
   426
      UNION ALL
sl@0
   427
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   428
      UNION ALL
sl@0
   429
      SELECT 9 FROM t2 WHERE y=3
sl@0
   430
      UNION ALL
sl@0
   431
      SELECT 10 FROM t2 WHERE y=4
sl@0
   432
    )
sl@0
   433
  }
sl@0
   434
} {1}
sl@0
   435
do_test tkt1473-5.7 {
sl@0
   436
  execsql {
sl@0
   437
    SELECT EXISTS (
sl@0
   438
      SELECT 1 FROM t2 WHERE x=0
sl@0
   439
      UNION ALL
sl@0
   440
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   441
      UNION ALL
sl@0
   442
      SELECT 3 FROM t2 WHERE x=2
sl@0
   443
      UNION ALL
sl@0
   444
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   445
      UNION ALL
sl@0
   446
      SELECT 5 FROM t2 WHERE x=4
sl@0
   447
      UNION ALL
sl@0
   448
      SELECT 6 FROM t2 WHERE y=0
sl@0
   449
      UNION ALL
sl@0
   450
      SELECT 7 FROM t2 WHERE y=1
sl@0
   451
      UNION ALL
sl@0
   452
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   453
      UNION ALL
sl@0
   454
      SELECT 9 FROM t2 WHERE y=3
sl@0
   455
      UNION ALL
sl@0
   456
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   457
    )
sl@0
   458
  }
sl@0
   459
} {0}
sl@0
   460
sl@0
   461
do_test tkt1473-6.3 {
sl@0
   462
  execsql {
sl@0
   463
    SELECT EXISTS (
sl@0
   464
      SELECT 1 FROM t2 WHERE x=0
sl@0
   465
      UNION
sl@0
   466
      SELECT 2 FROM t2 WHERE x=1
sl@0
   467
      UNION
sl@0
   468
      SELECT 3 FROM t2 WHERE x=2
sl@0
   469
      UNION
sl@0
   470
      SELECT 4 FROM t2 WHERE x=3
sl@0
   471
      UNION
sl@0
   472
      SELECT 5 FROM t2 WHERE x=4
sl@0
   473
      UNION
sl@0
   474
      SELECT 6 FROM t2 WHERE y=0
sl@0
   475
      UNION
sl@0
   476
      SELECT 7 FROM t2 WHERE y=1
sl@0
   477
      UNION
sl@0
   478
      SELECT 8 FROM t2 WHERE y=2
sl@0
   479
      UNION
sl@0
   480
      SELECT 9 FROM t2 WHERE y=3
sl@0
   481
      UNION
sl@0
   482
      SELECT 10 FROM t2 WHERE y=4
sl@0
   483
    )
sl@0
   484
  }
sl@0
   485
} {1}
sl@0
   486
do_test tkt1473-6.4 {
sl@0
   487
  execsql {
sl@0
   488
    SELECT EXISTS (
sl@0
   489
      SELECT 1 FROM t2 WHERE x=0
sl@0
   490
      UNION
sl@0
   491
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   492
      UNION
sl@0
   493
      SELECT 3 FROM t2 WHERE x=2
sl@0
   494
      UNION
sl@0
   495
      SELECT 4 FROM t2 WHERE x=3
sl@0
   496
      UNION
sl@0
   497
      SELECT 5 FROM t2 WHERE x=4
sl@0
   498
      UNION
sl@0
   499
      SELECT 6 FROM t2 WHERE y=0
sl@0
   500
      UNION
sl@0
   501
      SELECT 7 FROM t2 WHERE y=1
sl@0
   502
      UNION
sl@0
   503
      SELECT 8 FROM t2 WHERE y=2
sl@0
   504
      UNION
sl@0
   505
      SELECT 9 FROM t2 WHERE y=3
sl@0
   506
      UNION
sl@0
   507
      SELECT 10 FROM t2 WHERE y=4
sl@0
   508
    )
sl@0
   509
  }
sl@0
   510
} {1}
sl@0
   511
sl@0
   512
do_test tkt1473-6.5 {
sl@0
   513
  execsql {
sl@0
   514
    SELECT EXISTS (
sl@0
   515
      SELECT 1 FROM t2 WHERE x=0
sl@0
   516
      UNION
sl@0
   517
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   518
      UNION
sl@0
   519
      SELECT 3 FROM t2 WHERE x=2
sl@0
   520
      UNION
sl@0
   521
      SELECT 4 FROM t2 WHERE x=-1
sl@0
   522
      UNION
sl@0
   523
      SELECT 5 FROM t2 WHERE x=4
sl@0
   524
      UNION
sl@0
   525
      SELECT 6 FROM t2 WHERE y=0
sl@0
   526
      UNION
sl@0
   527
      SELECT 7 FROM t2 WHERE y=1
sl@0
   528
      UNION
sl@0
   529
      SELECT 8 FROM t2 WHERE y=2
sl@0
   530
      UNION
sl@0
   531
      SELECT 9 FROM t2 WHERE y=3
sl@0
   532
      UNION
sl@0
   533
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   534
    )
sl@0
   535
  }
sl@0
   536
} {1}
sl@0
   537
do_test tkt1473-6.6 {
sl@0
   538
  execsql {
sl@0
   539
    SELECT EXISTS (
sl@0
   540
      SELECT 1 FROM t2 WHERE x=0
sl@0
   541
      UNION
sl@0
   542
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   543
      UNION
sl@0
   544
      SELECT 3 FROM t2 WHERE x=2
sl@0
   545
      UNION
sl@0
   546
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   547
      UNION
sl@0
   548
      SELECT 5 FROM t2 WHERE x=4
sl@0
   549
      UNION
sl@0
   550
      SELECT 6 FROM t2 WHERE y=0
sl@0
   551
      UNION
sl@0
   552
      SELECT 7 FROM t2 WHERE y=1
sl@0
   553
      UNION
sl@0
   554
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   555
      UNION
sl@0
   556
      SELECT 9 FROM t2 WHERE y=3
sl@0
   557
      UNION
sl@0
   558
      SELECT 10 FROM t2 WHERE y=4
sl@0
   559
    )
sl@0
   560
  }
sl@0
   561
} {1}
sl@0
   562
do_test tkt1473-6.7 {
sl@0
   563
  execsql {
sl@0
   564
    SELECT EXISTS (
sl@0
   565
      SELECT 1 FROM t2 WHERE x=0
sl@0
   566
      UNION
sl@0
   567
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   568
      UNION
sl@0
   569
      SELECT 3 FROM t2 WHERE x=2
sl@0
   570
      UNION
sl@0
   571
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   572
      UNION
sl@0
   573
      SELECT 5 FROM t2 WHERE x=4
sl@0
   574
      UNION
sl@0
   575
      SELECT 6 FROM t2 WHERE y=0
sl@0
   576
      UNION
sl@0
   577
      SELECT 7 FROM t2 WHERE y=1
sl@0
   578
      UNION
sl@0
   579
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   580
      UNION
sl@0
   581
      SELECT 9 FROM t2 WHERE y=3
sl@0
   582
      UNION
sl@0
   583
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   584
    )
sl@0
   585
  }
sl@0
   586
} {0}
sl@0
   587
do_test tkt1473-6.8 {
sl@0
   588
  execsql {
sl@0
   589
    SELECT EXISTS (
sl@0
   590
      SELECT 1 FROM t2 WHERE x=0
sl@0
   591
      UNION
sl@0
   592
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   593
      UNION
sl@0
   594
      SELECT 3 FROM t2 WHERE x=2
sl@0
   595
      UNION
sl@0
   596
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   597
      UNION
sl@0
   598
      SELECT 5 FROM t2 WHERE x=4
sl@0
   599
      UNION ALL
sl@0
   600
      SELECT 6 FROM t2 WHERE y=0
sl@0
   601
      UNION
sl@0
   602
      SELECT 7 FROM t2 WHERE y=1
sl@0
   603
      UNION
sl@0
   604
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   605
      UNION
sl@0
   606
      SELECT 9 FROM t2 WHERE y=3
sl@0
   607
      UNION
sl@0
   608
      SELECT 10 FROM t2 WHERE y=4
sl@0
   609
    )
sl@0
   610
  }
sl@0
   611
} {1}
sl@0
   612
do_test tkt1473-6.9 {
sl@0
   613
  execsql {
sl@0
   614
    SELECT EXISTS (
sl@0
   615
      SELECT 1 FROM t2 WHERE x=0
sl@0
   616
      UNION
sl@0
   617
      SELECT 2 FROM t2 WHERE x=-1
sl@0
   618
      UNION
sl@0
   619
      SELECT 3 FROM t2 WHERE x=2
sl@0
   620
      UNION
sl@0
   621
      SELECT 4 FROM t2 WHERE x=-2
sl@0
   622
      UNION
sl@0
   623
      SELECT 5 FROM t2 WHERE x=4
sl@0
   624
      UNION ALL
sl@0
   625
      SELECT 6 FROM t2 WHERE y=0
sl@0
   626
      UNION
sl@0
   627
      SELECT 7 FROM t2 WHERE y=1
sl@0
   628
      UNION
sl@0
   629
      SELECT 8 FROM t2 WHERE y=-3
sl@0
   630
      UNION
sl@0
   631
      SELECT 9 FROM t2 WHERE y=3
sl@0
   632
      UNION
sl@0
   633
      SELECT 10 FROM t2 WHERE y=-4
sl@0
   634
    )
sl@0
   635
  }
sl@0
   636
} {0}
sl@0
   637
sl@0
   638
do_test tkt1473-7.1 {
sl@0
   639
  execsql {
sl@0
   640
    SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
sl@0
   641
  }
sl@0
   642
} {1}
sl@0
   643
do_test tkt1473-7.2 {
sl@0
   644
  execsql {
sl@0
   645
    SELECT (
sl@0
   646
      SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
sl@0
   647
    )
sl@0
   648
  }
sl@0
   649
} {1}
sl@0
   650
do_test tkt1473-7.3 {
sl@0
   651
  execsql {
sl@0
   652
    SELECT EXISTS (
sl@0
   653
      SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
sl@0
   654
    )
sl@0
   655
  }
sl@0
   656
} {1}
sl@0
   657
do_test tkt1473-7.4 {
sl@0
   658
  execsql {
sl@0
   659
    SELECT (
sl@0
   660
      SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2
sl@0
   661
    )
sl@0
   662
  }
sl@0
   663
} {{}}
sl@0
   664
do_test tkt1473-7.5 {
sl@0
   665
  execsql {
sl@0
   666
    SELECT EXISTS (
sl@0
   667
      SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2
sl@0
   668
    )
sl@0
   669
  }
sl@0
   670
} {0}
sl@0
   671
sl@0
   672
do_test tkt1473-8.1 {
sl@0
   673
  execsql {
sl@0
   674
    SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
sl@0
   675
  }
sl@0
   676
} {}
sl@0
   677
do_test tkt1473-8.1 {
sl@0
   678
  execsql {
sl@0
   679
    SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
sl@0
   680
  }
sl@0
   681
} {1}
sl@0
   682
do_test tkt1473-8.3 {
sl@0
   683
  execsql {
sl@0
   684
    SELECT (
sl@0
   685
      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
sl@0
   686
    )
sl@0
   687
  }
sl@0
   688
} {{}}
sl@0
   689
do_test tkt1473-8.4 {
sl@0
   690
  execsql {
sl@0
   691
    SELECT (
sl@0
   692
      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
sl@0
   693
    )
sl@0
   694
  }
sl@0
   695
} {1}
sl@0
   696
do_test tkt1473-8.5 {
sl@0
   697
  execsql {
sl@0
   698
    SELECT EXISTS (
sl@0
   699
      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
sl@0
   700
    )
sl@0
   701
  }
sl@0
   702
} {0}
sl@0
   703
do_test tkt1473-8.6 {
sl@0
   704
  execsql {
sl@0
   705
    SELECT EXISTS (
sl@0
   706
      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
sl@0
   707
    )
sl@0
   708
  }
sl@0
   709
} {1}
sl@0
   710
do_test tkt1473-8.7 {
sl@0
   711
  execsql {
sl@0
   712
    SELECT (
sl@0
   713
      SELECT 1 FROM t2 WHERE x=0 INTERSECT SELECT 1 FROM t2 WHERE y=2
sl@0
   714
    )
sl@0
   715
  }
sl@0
   716
} {{}}
sl@0
   717
do_test tkt1473-8.8 {
sl@0
   718
  execsql {
sl@0
   719
    SELECT EXISTS (
sl@0
   720
      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=0
sl@0
   721
    )
sl@0
   722
  }
sl@0
   723
} {0}
sl@0
   724
sl@0
   725
sl@0
   726
sl@0
   727
sl@0
   728
finish_test