os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/selectA.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
# 2008 June 24
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
# The focus of this file is testing the compound-SELECT merge
sl@0
    14
# optimization.  Or, in other words, making sure that all
sl@0
    15
# possible combinations of UNION, UNION ALL, EXCEPT, and
sl@0
    16
# INTERSECT work together with an ORDER BY clause (with or w/o
sl@0
    17
# explicit sort order and explicit collating secquites) and
sl@0
    18
# with and without optional LIMIT and OFFSET clauses.
sl@0
    19
#
sl@0
    20
# $Id: selectA.test,v 1.6 2008/08/21 14:24:29 drh Exp $
sl@0
    21
sl@0
    22
set testdir [file dirname $argv0]
sl@0
    23
source $testdir/tester.tcl
sl@0
    24
sl@0
    25
ifcapable !compound {
sl@0
    26
  finish_test
sl@0
    27
  return
sl@0
    28
}
sl@0
    29
sl@0
    30
do_test selectA-1.0 {
sl@0
    31
  execsql {
sl@0
    32
    CREATE TABLE t1(a,b,c COLLATE NOCASE);
sl@0
    33
    INSERT INTO t1 VALUES(1,'a','a');
sl@0
    34
    INSERT INTO t1 VALUES(9.9, 'b', 'B');
sl@0
    35
    INSERT INTO t1 VALUES(NULL, 'C', 'c');
sl@0
    36
    INSERT INTO t1 VALUES('hello', 'd', 'D');
sl@0
    37
    INSERT INTO t1 VALUES(x'616263', 'e', 'e');
sl@0
    38
    SELECT * FROM t1;
sl@0
    39
  }
sl@0
    40
} {1 a a 9.9 b B {} C c hello d D abc e e}
sl@0
    41
do_test selectA-1.1 {
sl@0
    42
  execsql {
sl@0
    43
    CREATE TABLE t2(x,y,z COLLATE NOCASE);
sl@0
    44
    INSERT INTO t2 VALUES(NULL,'U','u');
sl@0
    45
    INSERT INTO t2 VALUES('mad', 'Z', 'z');
sl@0
    46
    INSERT INTO t2 VALUES(x'68617265', 'm', 'M');
sl@0
    47
    INSERT INTO t2 VALUES(5.2e6, 'X', 'x');
sl@0
    48
    INSERT INTO t2 VALUES(-23, 'Y', 'y');
sl@0
    49
    SELECT * FROM t2;
sl@0
    50
  }
sl@0
    51
} {{} U u mad Z z hare m M 5200000.0 X x -23 Y y}
sl@0
    52
do_test selectA-1.2 {
sl@0
    53
  execsql {
sl@0
    54
    CREATE TABLE t3(a,b,c COLLATE NOCASE);
sl@0
    55
    INSERT INTO t3 SELECT * FROM t1;
sl@0
    56
    INSERT INTO t3 SELECT * FROM t2;
sl@0
    57
    INSERT INTO t3 SELECT * FROM t1;
sl@0
    58
    INSERT INTO t3 SELECT * FROM t2;
sl@0
    59
    INSERT INTO t3 SELECT * FROM t1;
sl@0
    60
    INSERT INTO t3 SELECT * FROM t2;
sl@0
    61
    SELECT count(*) FROM t3;
sl@0
    62
  }
sl@0
    63
} {30}
sl@0
    64
sl@0
    65
do_test selectA-2.1 {
sl@0
    66
  execsql {
sl@0
    67
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
    68
    ORDER BY a,b,c
sl@0
    69
  }
sl@0
    70
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
    71
do_test selectA-2.1.1 {   # Ticket #3314
sl@0
    72
  execsql {
sl@0
    73
    SELECT t1.a, t1.b, t1.c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
    74
    ORDER BY a,b,c
sl@0
    75
  }
sl@0
    76
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
    77
do_test selectA-2.1.2 {   # Ticket #3314
sl@0
    78
  execsql {
sl@0
    79
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
    80
    ORDER BY t1.a, t1.b, t1.c
sl@0
    81
  }
sl@0
    82
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
    83
do_test selectA-2.2 {
sl@0
    84
  execsql {
sl@0
    85
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
    86
    ORDER BY a DESC,b,c
sl@0
    87
  }
sl@0
    88
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
    89
do_test selectA-2.3 {
sl@0
    90
  execsql {
sl@0
    91
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
    92
    ORDER BY a,c,b
sl@0
    93
  }
sl@0
    94
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
    95
do_test selectA-2.4 {
sl@0
    96
  execsql {
sl@0
    97
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
    98
    ORDER BY b,a,c
sl@0
    99
  }
sl@0
   100
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   101
do_test selectA-2.5 {
sl@0
   102
  execsql {
sl@0
   103
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   104
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   105
  }
sl@0
   106
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   107
do_test selectA-2.6 {
sl@0
   108
  execsql {
sl@0
   109
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   110
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   111
  }
sl@0
   112
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   113
do_test selectA-2.7 {
sl@0
   114
  execsql {
sl@0
   115
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   116
    ORDER BY c,b,a
sl@0
   117
  }
sl@0
   118
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   119
do_test selectA-2.8 {
sl@0
   120
  execsql {
sl@0
   121
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   122
    ORDER BY c,a,b
sl@0
   123
  }
sl@0
   124
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   125
do_test selectA-2.9 {
sl@0
   126
  execsql {
sl@0
   127
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   128
    ORDER BY c DESC,a,b
sl@0
   129
  }
sl@0
   130
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   131
do_test selectA-2.10 {
sl@0
   132
  execsql {
sl@0
   133
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   134
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   135
  }
sl@0
   136
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   137
do_test selectA-2.11 {
sl@0
   138
  execsql {
sl@0
   139
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   140
    ORDER BY a,b,c
sl@0
   141
  }
sl@0
   142
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   143
do_test selectA-2.12 {
sl@0
   144
  execsql {
sl@0
   145
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   146
    ORDER BY a DESC,b,c
sl@0
   147
  }
sl@0
   148
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   149
do_test selectA-2.13 {
sl@0
   150
  execsql {
sl@0
   151
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   152
    ORDER BY a,c,b
sl@0
   153
  }
sl@0
   154
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   155
do_test selectA-2.14 {
sl@0
   156
  execsql {
sl@0
   157
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   158
    ORDER BY b,a,c
sl@0
   159
  }
sl@0
   160
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   161
do_test selectA-2.15 {
sl@0
   162
  execsql {
sl@0
   163
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   164
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   165
  }
sl@0
   166
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   167
do_test selectA-2.16 {
sl@0
   168
  execsql {
sl@0
   169
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   170
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   171
  }
sl@0
   172
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   173
do_test selectA-2.17 {
sl@0
   174
  execsql {
sl@0
   175
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   176
    ORDER BY c,b,a
sl@0
   177
  }
sl@0
   178
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   179
do_test selectA-2.18 {
sl@0
   180
  execsql {
sl@0
   181
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   182
    ORDER BY c,a,b
sl@0
   183
  }
sl@0
   184
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   185
do_test selectA-2.19 {
sl@0
   186
  execsql {
sl@0
   187
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   188
    ORDER BY c DESC,a,b
sl@0
   189
  }
sl@0
   190
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   191
do_test selectA-2.20 {
sl@0
   192
  execsql {
sl@0
   193
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   194
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   195
  }
sl@0
   196
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   197
do_test selectA-2.21 {
sl@0
   198
  execsql {
sl@0
   199
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   200
    ORDER BY a,b,c
sl@0
   201
  }
sl@0
   202
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   203
do_test selectA-2.22 {
sl@0
   204
  execsql {
sl@0
   205
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   206
    ORDER BY a DESC,b,c
sl@0
   207
  }
sl@0
   208
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   209
do_test selectA-2.23 {
sl@0
   210
  execsql {
sl@0
   211
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   212
    ORDER BY a,c,b
sl@0
   213
  }
sl@0
   214
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   215
do_test selectA-2.24 {
sl@0
   216
  execsql {
sl@0
   217
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   218
    ORDER BY b,a,c
sl@0
   219
  }
sl@0
   220
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   221
do_test selectA-2.25 {
sl@0
   222
  execsql {
sl@0
   223
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   224
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   225
  }
sl@0
   226
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   227
do_test selectA-2.26 {
sl@0
   228
  execsql {
sl@0
   229
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   230
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   231
  }
sl@0
   232
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   233
do_test selectA-2.27 {
sl@0
   234
  execsql {
sl@0
   235
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   236
    ORDER BY c,b,a
sl@0
   237
  }
sl@0
   238
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   239
do_test selectA-2.28 {
sl@0
   240
  execsql {
sl@0
   241
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   242
    ORDER BY c,a,b
sl@0
   243
  }
sl@0
   244
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   245
do_test selectA-2.29 {
sl@0
   246
  execsql {
sl@0
   247
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   248
    ORDER BY c DESC,a,b
sl@0
   249
  }
sl@0
   250
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   251
do_test selectA-2.30 {
sl@0
   252
  execsql {
sl@0
   253
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   254
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   255
  }
sl@0
   256
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   257
do_test selectA-2.31 {
sl@0
   258
  execsql {
sl@0
   259
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   260
    ORDER BY a,b,c
sl@0
   261
  }
sl@0
   262
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   263
do_test selectA-2.32 {
sl@0
   264
  execsql {
sl@0
   265
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   266
    ORDER BY a DESC,b,c
sl@0
   267
  }
sl@0
   268
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   269
do_test selectA-2.33 {
sl@0
   270
  execsql {
sl@0
   271
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   272
    ORDER BY a,c,b
sl@0
   273
  }
sl@0
   274
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   275
do_test selectA-2.34 {
sl@0
   276
  execsql {
sl@0
   277
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   278
    ORDER BY b,a,c
sl@0
   279
  }
sl@0
   280
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   281
do_test selectA-2.35 {
sl@0
   282
  execsql {
sl@0
   283
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   284
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   285
  }
sl@0
   286
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   287
do_test selectA-2.36 {
sl@0
   288
  execsql {
sl@0
   289
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   290
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   291
  }
sl@0
   292
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   293
do_test selectA-2.37 {
sl@0
   294
  execsql {
sl@0
   295
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   296
    ORDER BY c,b,a
sl@0
   297
  }
sl@0
   298
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   299
do_test selectA-2.38 {
sl@0
   300
  execsql {
sl@0
   301
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   302
    ORDER BY c,a,b
sl@0
   303
  }
sl@0
   304
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   305
do_test selectA-2.39 {
sl@0
   306
  execsql {
sl@0
   307
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   308
    ORDER BY c DESC,a,b
sl@0
   309
  }
sl@0
   310
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   311
do_test selectA-2.40 {
sl@0
   312
  execsql {
sl@0
   313
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   314
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   315
  }
sl@0
   316
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   317
do_test selectA-2.41 {
sl@0
   318
  execsql {
sl@0
   319
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   320
    ORDER BY a,b,c
sl@0
   321
  }
sl@0
   322
} {{} C c 1 a a 9.9 b B}
sl@0
   323
do_test selectA-2.42 {
sl@0
   324
  execsql {
sl@0
   325
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   326
    ORDER BY a,b,c
sl@0
   327
  }
sl@0
   328
} {hello d D abc e e}
sl@0
   329
do_test selectA-2.43 {
sl@0
   330
  execsql {
sl@0
   331
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
   332
    ORDER BY a,b,c
sl@0
   333
  }
sl@0
   334
} {hello d D abc e e}
sl@0
   335
do_test selectA-2.44 {
sl@0
   336
  execsql {
sl@0
   337
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   338
    ORDER BY a,b,c
sl@0
   339
  }
sl@0
   340
} {hello d D abc e e}
sl@0
   341
do_test selectA-2.45 {
sl@0
   342
  execsql {
sl@0
   343
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   344
    ORDER BY a,b,c
sl@0
   345
  }
sl@0
   346
} {{} C c 1 a a 9.9 b B}
sl@0
   347
do_test selectA-2.46 {
sl@0
   348
  execsql {
sl@0
   349
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   350
    ORDER BY a,b,c
sl@0
   351
  }
sl@0
   352
} {{} C c 1 a a 9.9 b B}
sl@0
   353
do_test selectA-2.47 {
sl@0
   354
  execsql {
sl@0
   355
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   356
    ORDER BY a DESC
sl@0
   357
  }
sl@0
   358
} {9.9 b B 1 a a {} C c}
sl@0
   359
do_test selectA-2.48 {
sl@0
   360
  execsql {
sl@0
   361
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   362
    ORDER BY a DESC
sl@0
   363
  }
sl@0
   364
} {abc e e hello d D}
sl@0
   365
do_test selectA-2.49 {
sl@0
   366
  execsql {
sl@0
   367
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
   368
    ORDER BY a DESC
sl@0
   369
  }
sl@0
   370
} {abc e e hello d D}
sl@0
   371
do_test selectA-2.50 {
sl@0
   372
  execsql {
sl@0
   373
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   374
    ORDER BY a DESC
sl@0
   375
  }
sl@0
   376
} {abc e e hello d D}
sl@0
   377
do_test selectA-2.51 {
sl@0
   378
  execsql {
sl@0
   379
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   380
    ORDER BY a DESC
sl@0
   381
  }
sl@0
   382
} {9.9 b B 1 a a {} C c}
sl@0
   383
do_test selectA-2.52 {
sl@0
   384
  execsql {
sl@0
   385
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   386
    ORDER BY a DESC
sl@0
   387
  }
sl@0
   388
} {9.9 b B 1 a a {} C c}
sl@0
   389
do_test selectA-2.53 {
sl@0
   390
  execsql {
sl@0
   391
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   392
    ORDER BY b, a DESC
sl@0
   393
  }
sl@0
   394
} {{} C c 1 a a 9.9 b B}
sl@0
   395
do_test selectA-2.54 {
sl@0
   396
  execsql {
sl@0
   397
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   398
    ORDER BY b
sl@0
   399
  }
sl@0
   400
} {hello d D abc e e}
sl@0
   401
do_test selectA-2.55 {
sl@0
   402
  execsql {
sl@0
   403
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
   404
    ORDER BY b DESC, c
sl@0
   405
  }
sl@0
   406
} {abc e e hello d D}
sl@0
   407
do_test selectA-2.56 {
sl@0
   408
  execsql {
sl@0
   409
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   410
    ORDER BY b, c DESC, a
sl@0
   411
  }
sl@0
   412
} {hello d D abc e e}
sl@0
   413
do_test selectA-2.57 {
sl@0
   414
  execsql {
sl@0
   415
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   416
    ORDER BY b COLLATE NOCASE
sl@0
   417
  }
sl@0
   418
} {1 a a 9.9 b B {} C c}
sl@0
   419
do_test selectA-2.58 {
sl@0
   420
  execsql {
sl@0
   421
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   422
    ORDER BY b
sl@0
   423
  }
sl@0
   424
} {{} C c 1 a a 9.9 b B}
sl@0
   425
do_test selectA-2.59 {
sl@0
   426
  execsql {
sl@0
   427
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   428
    ORDER BY c, a DESC
sl@0
   429
  }
sl@0
   430
} {1 a a 9.9 b B {} C c}
sl@0
   431
do_test selectA-2.60 {
sl@0
   432
  execsql {
sl@0
   433
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   434
    ORDER BY c
sl@0
   435
  }
sl@0
   436
} {hello d D abc e e}
sl@0
   437
do_test selectA-2.61 {
sl@0
   438
  execsql {
sl@0
   439
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
   440
    ORDER BY c COLLATE BINARY, b DESC, c, a, b, c, a, b, c
sl@0
   441
  }
sl@0
   442
} {hello d D abc e e}
sl@0
   443
do_test selectA-2.62 {
sl@0
   444
  execsql {
sl@0
   445
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   446
    ORDER BY c DESC, a
sl@0
   447
  }
sl@0
   448
} {abc e e hello d D}
sl@0
   449
do_test selectA-2.63 {
sl@0
   450
  execsql {
sl@0
   451
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   452
    ORDER BY c COLLATE NOCASE
sl@0
   453
  }
sl@0
   454
} {1 a a 9.9 b B {} C c}
sl@0
   455
do_test selectA-2.64 {
sl@0
   456
  execsql {
sl@0
   457
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   458
    ORDER BY c
sl@0
   459
  }
sl@0
   460
} {1 a a 9.9 b B {} C c}
sl@0
   461
do_test selectA-2.65 {
sl@0
   462
  execsql {
sl@0
   463
    SELECT a,b,c FROM t3 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   464
    ORDER BY c COLLATE NOCASE
sl@0
   465
  }
sl@0
   466
} {1 a a 9.9 b B {} C c}
sl@0
   467
do_test selectA-2.66 {
sl@0
   468
  execsql {
sl@0
   469
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t3
sl@0
   470
    ORDER BY c
sl@0
   471
  }
sl@0
   472
} {1 a a 9.9 b B {} C c}
sl@0
   473
do_test selectA-2.67 {
sl@0
   474
  execsql {
sl@0
   475
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t3 WHERE b<'d'
sl@0
   476
    ORDER BY c DESC, a
sl@0
   477
  }
sl@0
   478
} {abc e e hello d D}
sl@0
   479
do_test selectA-2.68 {
sl@0
   480
  execsql {
sl@0
   481
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   482
    INTERSECT SELECT a,b,c FROM t3
sl@0
   483
    EXCEPT SELECT b,c,a FROM t3
sl@0
   484
    ORDER BY c DESC, a
sl@0
   485
  }
sl@0
   486
} {abc e e hello d D}
sl@0
   487
do_test selectA-2.69 {
sl@0
   488
  execsql {
sl@0
   489
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   490
    INTERSECT SELECT a,b,c FROM t3
sl@0
   491
    EXCEPT SELECT b,c,a FROM t3
sl@0
   492
    ORDER BY c COLLATE NOCASE
sl@0
   493
  }
sl@0
   494
} {1 a a 9.9 b B {} C c}
sl@0
   495
do_test selectA-2.70 {
sl@0
   496
  execsql {
sl@0
   497
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   498
    INTERSECT SELECT a,b,c FROM t3
sl@0
   499
    EXCEPT SELECT b,c,a FROM t3
sl@0
   500
    ORDER BY c
sl@0
   501
  }
sl@0
   502
} {1 a a 9.9 b B {} C c}
sl@0
   503
do_test selectA-2.71 {
sl@0
   504
  execsql {
sl@0
   505
    SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   506
    INTERSECT SELECT a,b,c FROM t1
sl@0
   507
    INTERSECT SELECT a,b,c FROM t3
sl@0
   508
    EXCEPT SELECT b,c,a FROM t3
sl@0
   509
    INTERSECT SELECT a,b,c FROM t1
sl@0
   510
    EXCEPT SELECT x,y,z FROM t2
sl@0
   511
    INTERSECT SELECT a,b,c FROM t3
sl@0
   512
    EXCEPT SELECT y,x,z FROM t2
sl@0
   513
    INTERSECT SELECT a,b,c FROM t1
sl@0
   514
    EXCEPT SELECT c,b,a FROM t3
sl@0
   515
    ORDER BY c
sl@0
   516
  }
sl@0
   517
} {1 a a 9.9 b B {} C c}
sl@0
   518
do_test selectA-2.72 {
sl@0
   519
  execsql {
sl@0
   520
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   521
    ORDER BY a,b,c
sl@0
   522
  }
sl@0
   523
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   524
do_test selectA-2.73 {
sl@0
   525
  execsql {
sl@0
   526
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   527
    ORDER BY a DESC,b,c
sl@0
   528
  }
sl@0
   529
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   530
do_test selectA-2.74 {
sl@0
   531
  execsql {
sl@0
   532
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   533
    ORDER BY a,c,b
sl@0
   534
  }
sl@0
   535
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   536
do_test selectA-2.75 {
sl@0
   537
  execsql {
sl@0
   538
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   539
    ORDER BY b,a,c
sl@0
   540
  }
sl@0
   541
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   542
do_test selectA-2.76 {
sl@0
   543
  execsql {
sl@0
   544
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   545
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   546
  }
sl@0
   547
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   548
do_test selectA-2.77 {
sl@0
   549
  execsql {
sl@0
   550
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   551
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   552
  }
sl@0
   553
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   554
do_test selectA-2.78 {
sl@0
   555
  execsql {
sl@0
   556
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   557
    ORDER BY c,b,a
sl@0
   558
  }
sl@0
   559
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   560
do_test selectA-2.79 {
sl@0
   561
  execsql {
sl@0
   562
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   563
    ORDER BY c,a,b
sl@0
   564
  }
sl@0
   565
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   566
do_test selectA-2.80 {
sl@0
   567
  execsql {
sl@0
   568
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   569
    ORDER BY c DESC,a,b
sl@0
   570
  }
sl@0
   571
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   572
do_test selectA-2.81 {
sl@0
   573
  execsql {
sl@0
   574
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
   575
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   576
  }
sl@0
   577
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   578
do_test selectA-2.82 {
sl@0
   579
  execsql {
sl@0
   580
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   581
    ORDER BY a,b,c
sl@0
   582
  }
sl@0
   583
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   584
do_test selectA-2.83 {
sl@0
   585
  execsql {
sl@0
   586
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   587
    ORDER BY a DESC,b,c
sl@0
   588
  }
sl@0
   589
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   590
do_test selectA-2.84 {
sl@0
   591
  execsql {
sl@0
   592
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   593
    ORDER BY a,c,b
sl@0
   594
  }
sl@0
   595
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   596
do_test selectA-2.85 {
sl@0
   597
  execsql {
sl@0
   598
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   599
    ORDER BY b,a,c
sl@0
   600
  }
sl@0
   601
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   602
do_test selectA-2.86 {
sl@0
   603
  execsql {
sl@0
   604
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   605
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   606
  }
sl@0
   607
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   608
do_test selectA-2.87 {
sl@0
   609
  execsql {
sl@0
   610
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   611
    ORDER BY y COLLATE NOCASE DESC,x,z
sl@0
   612
  }
sl@0
   613
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   614
do_test selectA-2.88 {
sl@0
   615
  execsql {
sl@0
   616
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   617
    ORDER BY c,b,a
sl@0
   618
  }
sl@0
   619
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   620
do_test selectA-2.89 {
sl@0
   621
  execsql {
sl@0
   622
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   623
    ORDER BY c,a,b
sl@0
   624
  }
sl@0
   625
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   626
do_test selectA-2.90 {
sl@0
   627
  execsql {
sl@0
   628
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   629
    ORDER BY c DESC,a,b
sl@0
   630
  }
sl@0
   631
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   632
do_test selectA-2.91 {
sl@0
   633
  execsql {
sl@0
   634
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
   635
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   636
  }
sl@0
   637
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   638
do_test selectA-2.92 {
sl@0
   639
  execsql {
sl@0
   640
    SELECT x,y,z FROM t2
sl@0
   641
    INTERSECT SELECT a,b,c FROM t3
sl@0
   642
    EXCEPT SELECT c,b,a FROM t1
sl@0
   643
    UNION SELECT a,b,c FROM t3
sl@0
   644
    INTERSECT SELECT a,b,c FROM t3
sl@0
   645
    EXCEPT SELECT c,b,a FROM t1
sl@0
   646
    UNION SELECT a,b,c FROM t3
sl@0
   647
    ORDER BY y COLLATE NOCASE DESC,x,z
sl@0
   648
  }
sl@0
   649
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   650
do_test selectA-2.93 {
sl@0
   651
  execsql {
sl@0
   652
    SELECT upper((SELECT c FROM t1 UNION SELECT z FROM t2 ORDER BY 1));
sl@0
   653
  }
sl@0
   654
} {A}
sl@0
   655
do_test selectA-2.94 {
sl@0
   656
  execsql {
sl@0
   657
    SELECT lower((SELECT c FROM t1 UNION ALL SELECT z FROM t2 ORDER BY 1));
sl@0
   658
  }
sl@0
   659
} {a}
sl@0
   660
do_test selectA-2.95 {
sl@0
   661
  execsql {
sl@0
   662
    SELECT lower((SELECT c FROM t1 INTERSECT SELECT z FROM t2 ORDER BY 1));
sl@0
   663
  }
sl@0
   664
} {{}}
sl@0
   665
do_test selectA-2.96 {
sl@0
   666
  execsql {
sl@0
   667
    SELECT lower((SELECT z FROM t2 EXCEPT SELECT c FROM t1 ORDER BY 1));
sl@0
   668
  }
sl@0
   669
} {m}
sl@0
   670
sl@0
   671
sl@0
   672
do_test selectA-3.0 {
sl@0
   673
  execsql {
sl@0
   674
    CREATE UNIQUE INDEX t1a ON t1(a);
sl@0
   675
    CREATE UNIQUE INDEX t1b ON t1(b);
sl@0
   676
    CREATE UNIQUE INDEX t1c ON t1(c);
sl@0
   677
    CREATE UNIQUE INDEX t2x ON t2(x);
sl@0
   678
    CREATE UNIQUE INDEX t2y ON t2(y);
sl@0
   679
    CREATE UNIQUE INDEX t2z ON t2(z);
sl@0
   680
    SELECT name FROM sqlite_master WHERE type='index'
sl@0
   681
  }
sl@0
   682
} {t1a t1b t1c t2x t2y t2z}
sl@0
   683
do_test selectA-3.1 {
sl@0
   684
  execsql {
sl@0
   685
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   686
    ORDER BY a,b,c
sl@0
   687
  }
sl@0
   688
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   689
do_test selectA-3.1.1 {  # Ticket #3314
sl@0
   690
  execsql {
sl@0
   691
    SELECT t1.a,b,t1.c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   692
    ORDER BY a,t1.b,t1.c
sl@0
   693
  }
sl@0
   694
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   695
do_test selectA-3.2 {
sl@0
   696
  execsql {
sl@0
   697
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   698
    ORDER BY a DESC,b,c
sl@0
   699
  }
sl@0
   700
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   701
do_test selectA-3.3 {
sl@0
   702
  execsql {
sl@0
   703
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   704
    ORDER BY a,c,b
sl@0
   705
  }
sl@0
   706
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   707
do_test selectA-3.4 {
sl@0
   708
  execsql {
sl@0
   709
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   710
    ORDER BY b,a,c
sl@0
   711
  }
sl@0
   712
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   713
do_test selectA-3.5 {
sl@0
   714
  execsql {
sl@0
   715
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   716
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   717
  }
sl@0
   718
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   719
do_test selectA-3.6 {
sl@0
   720
  execsql {
sl@0
   721
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   722
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   723
  }
sl@0
   724
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   725
do_test selectA-3.7 {
sl@0
   726
  execsql {
sl@0
   727
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   728
    ORDER BY c,b,a
sl@0
   729
  }
sl@0
   730
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   731
do_test selectA-3.8 {
sl@0
   732
  execsql {
sl@0
   733
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   734
    ORDER BY c,a,b
sl@0
   735
  }
sl@0
   736
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   737
do_test selectA-3.9 {
sl@0
   738
  execsql {
sl@0
   739
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   740
    ORDER BY c DESC,a,b
sl@0
   741
  }
sl@0
   742
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   743
do_test selectA-3.10 {
sl@0
   744
  execsql {
sl@0
   745
    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2
sl@0
   746
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   747
  }
sl@0
   748
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   749
do_test selectA-3.11 {
sl@0
   750
  execsql {
sl@0
   751
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   752
    ORDER BY a,b,c
sl@0
   753
  }
sl@0
   754
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   755
do_test selectA-3.12 {
sl@0
   756
  execsql {
sl@0
   757
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   758
    ORDER BY a DESC,b,c
sl@0
   759
  }
sl@0
   760
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   761
do_test selectA-3.13 {
sl@0
   762
  execsql {
sl@0
   763
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   764
    ORDER BY a,c,b
sl@0
   765
  }
sl@0
   766
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   767
do_test selectA-3.14 {
sl@0
   768
  execsql {
sl@0
   769
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   770
    ORDER BY b,a,c
sl@0
   771
  }
sl@0
   772
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   773
do_test selectA-3.15 {
sl@0
   774
  execsql {
sl@0
   775
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   776
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   777
  }
sl@0
   778
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   779
do_test selectA-3.16 {
sl@0
   780
  execsql {
sl@0
   781
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   782
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   783
  }
sl@0
   784
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   785
do_test selectA-3.17 {
sl@0
   786
  execsql {
sl@0
   787
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   788
    ORDER BY c,b,a
sl@0
   789
  }
sl@0
   790
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   791
do_test selectA-3.18 {
sl@0
   792
  execsql {
sl@0
   793
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   794
    ORDER BY c,a,b
sl@0
   795
  }
sl@0
   796
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   797
do_test selectA-3.19 {
sl@0
   798
  execsql {
sl@0
   799
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   800
    ORDER BY c DESC,a,b
sl@0
   801
  }
sl@0
   802
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   803
do_test selectA-3.20 {
sl@0
   804
  execsql {
sl@0
   805
    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1
sl@0
   806
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   807
  }
sl@0
   808
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   809
do_test selectA-3.21 {
sl@0
   810
  execsql {
sl@0
   811
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   812
    ORDER BY a,b,c
sl@0
   813
  }
sl@0
   814
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   815
do_test selectA-3.22 {
sl@0
   816
  execsql {
sl@0
   817
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   818
    ORDER BY a DESC,b,c
sl@0
   819
  }
sl@0
   820
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   821
do_test selectA-3.23 {
sl@0
   822
  execsql {
sl@0
   823
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   824
    ORDER BY a,c,b
sl@0
   825
  }
sl@0
   826
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   827
do_test selectA-3.24 {
sl@0
   828
  execsql {
sl@0
   829
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   830
    ORDER BY b,a,c
sl@0
   831
  }
sl@0
   832
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   833
do_test selectA-3.25 {
sl@0
   834
  execsql {
sl@0
   835
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   836
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   837
  }
sl@0
   838
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   839
do_test selectA-3.26 {
sl@0
   840
  execsql {
sl@0
   841
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   842
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   843
  }
sl@0
   844
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   845
do_test selectA-3.27 {
sl@0
   846
  execsql {
sl@0
   847
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   848
    ORDER BY c,b,a
sl@0
   849
  }
sl@0
   850
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   851
do_test selectA-3.28 {
sl@0
   852
  execsql {
sl@0
   853
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   854
    ORDER BY c,a,b
sl@0
   855
  }
sl@0
   856
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   857
do_test selectA-3.29 {
sl@0
   858
  execsql {
sl@0
   859
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   860
    ORDER BY c DESC,a,b
sl@0
   861
  }
sl@0
   862
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   863
do_test selectA-3.30 {
sl@0
   864
  execsql {
sl@0
   865
    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2
sl@0
   866
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   867
  }
sl@0
   868
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   869
do_test selectA-3.31 {
sl@0
   870
  execsql {
sl@0
   871
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   872
    ORDER BY a,b,c
sl@0
   873
  }
sl@0
   874
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   875
do_test selectA-3.32 {
sl@0
   876
  execsql {
sl@0
   877
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   878
    ORDER BY a DESC,b,c
sl@0
   879
  }
sl@0
   880
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
   881
do_test selectA-3.33 {
sl@0
   882
  execsql {
sl@0
   883
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   884
    ORDER BY a,c,b
sl@0
   885
  }
sl@0
   886
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
   887
do_test selectA-3.34 {
sl@0
   888
  execsql {
sl@0
   889
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   890
    ORDER BY b,a,c
sl@0
   891
  }
sl@0
   892
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
   893
do_test selectA-3.35 {
sl@0
   894
  execsql {
sl@0
   895
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   896
    ORDER BY b COLLATE NOCASE,a,c
sl@0
   897
  }
sl@0
   898
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   899
do_test selectA-3.36 {
sl@0
   900
  execsql {
sl@0
   901
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   902
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
   903
  }
sl@0
   904
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   905
do_test selectA-3.37 {
sl@0
   906
  execsql {
sl@0
   907
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   908
    ORDER BY c,b,a
sl@0
   909
  }
sl@0
   910
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   911
do_test selectA-3.38 {
sl@0
   912
  execsql {
sl@0
   913
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   914
    ORDER BY c,a,b
sl@0
   915
  }
sl@0
   916
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
   917
do_test selectA-3.39 {
sl@0
   918
  execsql {
sl@0
   919
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   920
    ORDER BY c DESC,a,b
sl@0
   921
  }
sl@0
   922
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
   923
do_test selectA-3.40 {
sl@0
   924
  execsql {
sl@0
   925
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1
sl@0
   926
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
   927
  }
sl@0
   928
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
   929
do_test selectA-3.41 {
sl@0
   930
  execsql {
sl@0
   931
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   932
    ORDER BY a,b,c
sl@0
   933
  }
sl@0
   934
} {{} C c 1 a a 9.9 b B}
sl@0
   935
do_test selectA-3.42 {
sl@0
   936
  execsql {
sl@0
   937
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   938
    ORDER BY a,b,c
sl@0
   939
  }
sl@0
   940
} {hello d D abc e e}
sl@0
   941
do_test selectA-3.43 {
sl@0
   942
  execsql {
sl@0
   943
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
   944
    ORDER BY a,b,c
sl@0
   945
  }
sl@0
   946
} {hello d D abc e e}
sl@0
   947
do_test selectA-3.44 {
sl@0
   948
  execsql {
sl@0
   949
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   950
    ORDER BY a,b,c
sl@0
   951
  }
sl@0
   952
} {hello d D abc e e}
sl@0
   953
do_test selectA-3.45 {
sl@0
   954
  execsql {
sl@0
   955
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   956
    ORDER BY a,b,c
sl@0
   957
  }
sl@0
   958
} {{} C c 1 a a 9.9 b B}
sl@0
   959
do_test selectA-3.46 {
sl@0
   960
  execsql {
sl@0
   961
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   962
    ORDER BY a,b,c
sl@0
   963
  }
sl@0
   964
} {{} C c 1 a a 9.9 b B}
sl@0
   965
do_test selectA-3.47 {
sl@0
   966
  execsql {
sl@0
   967
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   968
    ORDER BY a DESC
sl@0
   969
  }
sl@0
   970
} {9.9 b B 1 a a {} C c}
sl@0
   971
do_test selectA-3.48 {
sl@0
   972
  execsql {
sl@0
   973
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
   974
    ORDER BY a DESC
sl@0
   975
  }
sl@0
   976
} {abc e e hello d D}
sl@0
   977
do_test selectA-3.49 {
sl@0
   978
  execsql {
sl@0
   979
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
   980
    ORDER BY a DESC
sl@0
   981
  }
sl@0
   982
} {abc e e hello d D}
sl@0
   983
do_test selectA-3.50 {
sl@0
   984
  execsql {
sl@0
   985
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   986
    ORDER BY a DESC
sl@0
   987
  }
sl@0
   988
} {abc e e hello d D}
sl@0
   989
do_test selectA-3.51 {
sl@0
   990
  execsql {
sl@0
   991
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
   992
    ORDER BY a DESC
sl@0
   993
  }
sl@0
   994
} {9.9 b B 1 a a {} C c}
sl@0
   995
do_test selectA-3.52 {
sl@0
   996
  execsql {
sl@0
   997
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
   998
    ORDER BY a DESC
sl@0
   999
  }
sl@0
  1000
} {9.9 b B 1 a a {} C c}
sl@0
  1001
do_test selectA-3.53 {
sl@0
  1002
  execsql {
sl@0
  1003
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
  1004
    ORDER BY b, a DESC
sl@0
  1005
  }
sl@0
  1006
} {{} C c 1 a a 9.9 b B}
sl@0
  1007
do_test selectA-3.54 {
sl@0
  1008
  execsql {
sl@0
  1009
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
  1010
    ORDER BY b
sl@0
  1011
  }
sl@0
  1012
} {hello d D abc e e}
sl@0
  1013
do_test selectA-3.55 {
sl@0
  1014
  execsql {
sl@0
  1015
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
  1016
    ORDER BY b DESC, c
sl@0
  1017
  }
sl@0
  1018
} {abc e e hello d D}
sl@0
  1019
do_test selectA-3.56 {
sl@0
  1020
  execsql {
sl@0
  1021
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1022
    ORDER BY b, c DESC, a
sl@0
  1023
  }
sl@0
  1024
} {hello d D abc e e}
sl@0
  1025
do_test selectA-3.57 {
sl@0
  1026
  execsql {
sl@0
  1027
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1028
    ORDER BY b COLLATE NOCASE
sl@0
  1029
  }
sl@0
  1030
} {1 a a 9.9 b B {} C c}
sl@0
  1031
do_test selectA-3.58 {
sl@0
  1032
  execsql {
sl@0
  1033
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
  1034
    ORDER BY b
sl@0
  1035
  }
sl@0
  1036
} {{} C c 1 a a 9.9 b B}
sl@0
  1037
do_test selectA-3.59 {
sl@0
  1038
  execsql {
sl@0
  1039
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
  1040
    ORDER BY c, a DESC
sl@0
  1041
  }
sl@0
  1042
} {1 a a 9.9 b B {} C c}
sl@0
  1043
do_test selectA-3.60 {
sl@0
  1044
  execsql {
sl@0
  1045
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'
sl@0
  1046
    ORDER BY c
sl@0
  1047
  }
sl@0
  1048
} {hello d D abc e e}
sl@0
  1049
do_test selectA-3.61 {
sl@0
  1050
  execsql {
sl@0
  1051
    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1
sl@0
  1052
    ORDER BY c COLLATE BINARY, b DESC, c, a, b, c, a, b, c
sl@0
  1053
  }
sl@0
  1054
} {hello d D abc e e}
sl@0
  1055
do_test selectA-3.62 {
sl@0
  1056
  execsql {
sl@0
  1057
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1058
    ORDER BY c DESC, a
sl@0
  1059
  }
sl@0
  1060
} {abc e e hello d D}
sl@0
  1061
do_test selectA-3.63 {
sl@0
  1062
  execsql {
sl@0
  1063
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1064
    ORDER BY c COLLATE NOCASE
sl@0
  1065
  }
sl@0
  1066
} {1 a a 9.9 b B {} C c}
sl@0
  1067
do_test selectA-3.64 {
sl@0
  1068
  execsql {
sl@0
  1069
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
  1070
    ORDER BY c
sl@0
  1071
  }
sl@0
  1072
} {1 a a 9.9 b B {} C c}
sl@0
  1073
do_test selectA-3.65 {
sl@0
  1074
  execsql {
sl@0
  1075
    SELECT a,b,c FROM t3 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1076
    ORDER BY c COLLATE NOCASE
sl@0
  1077
  }
sl@0
  1078
} {1 a a 9.9 b B {} C c}
sl@0
  1079
do_test selectA-3.66 {
sl@0
  1080
  execsql {
sl@0
  1081
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t3
sl@0
  1082
    ORDER BY c
sl@0
  1083
  }
sl@0
  1084
} {1 a a 9.9 b B {} C c}
sl@0
  1085
do_test selectA-3.67 {
sl@0
  1086
  execsql {
sl@0
  1087
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t3 WHERE b<'d'
sl@0
  1088
    ORDER BY c DESC, a
sl@0
  1089
  }
sl@0
  1090
} {abc e e hello d D}
sl@0
  1091
do_test selectA-3.68 {
sl@0
  1092
  execsql {
sl@0
  1093
    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1094
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1095
    EXCEPT SELECT b,c,a FROM t3
sl@0
  1096
    ORDER BY c DESC, a
sl@0
  1097
  }
sl@0
  1098
} {abc e e hello d D}
sl@0
  1099
do_test selectA-3.69 {
sl@0
  1100
  execsql {
sl@0
  1101
    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1102
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1103
    EXCEPT SELECT b,c,a FROM t3
sl@0
  1104
    ORDER BY c COLLATE NOCASE
sl@0
  1105
  }
sl@0
  1106
} {1 a a 9.9 b B {} C c}
sl@0
  1107
do_test selectA-3.70 {
sl@0
  1108
  execsql {
sl@0
  1109
    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1
sl@0
  1110
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1111
    EXCEPT SELECT b,c,a FROM t3
sl@0
  1112
    ORDER BY c
sl@0
  1113
  }
sl@0
  1114
} {1 a a 9.9 b B {} C c}
sl@0
  1115
do_test selectA-3.71 {
sl@0
  1116
  execsql {
sl@0
  1117
    SELECT a,b,c FROM t1 WHERE b<'d'
sl@0
  1118
    INTERSECT SELECT a,b,c FROM t1
sl@0
  1119
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1120
    EXCEPT SELECT b,c,a FROM t3
sl@0
  1121
    INTERSECT SELECT a,b,c FROM t1
sl@0
  1122
    EXCEPT SELECT x,y,z FROM t2
sl@0
  1123
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1124
    EXCEPT SELECT y,x,z FROM t2
sl@0
  1125
    INTERSECT SELECT a,b,c FROM t1
sl@0
  1126
    EXCEPT SELECT c,b,a FROM t3
sl@0
  1127
    ORDER BY c
sl@0
  1128
  }
sl@0
  1129
} {1 a a 9.9 b B {} C c}
sl@0
  1130
do_test selectA-3.72 {
sl@0
  1131
  execsql {
sl@0
  1132
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1133
    ORDER BY a,b,c
sl@0
  1134
  }
sl@0
  1135
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
  1136
do_test selectA-3.73 {
sl@0
  1137
  execsql {
sl@0
  1138
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1139
    ORDER BY a DESC,b,c
sl@0
  1140
  }
sl@0
  1141
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
  1142
do_test selectA-3.74 {
sl@0
  1143
  execsql {
sl@0
  1144
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1145
    ORDER BY a,c,b
sl@0
  1146
  }
sl@0
  1147
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
  1148
do_test selectA-3.75 {
sl@0
  1149
  execsql {
sl@0
  1150
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1151
    ORDER BY b,a,c
sl@0
  1152
  }
sl@0
  1153
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
  1154
do_test selectA-3.76 {
sl@0
  1155
  execsql {
sl@0
  1156
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1157
    ORDER BY b COLLATE NOCASE,a,c
sl@0
  1158
  }
sl@0
  1159
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
  1160
do_test selectA-3.77 {
sl@0
  1161
  execsql {
sl@0
  1162
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1163
    ORDER BY b COLLATE NOCASE DESC,a,c
sl@0
  1164
  }
sl@0
  1165
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
  1166
do_test selectA-3.78 {
sl@0
  1167
  execsql {
sl@0
  1168
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1169
    ORDER BY c,b,a
sl@0
  1170
  }
sl@0
  1171
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
  1172
do_test selectA-3.79 {
sl@0
  1173
  execsql {
sl@0
  1174
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1175
    ORDER BY c,a,b
sl@0
  1176
  }
sl@0
  1177
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
  1178
do_test selectA-3.80 {
sl@0
  1179
  execsql {
sl@0
  1180
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1181
    ORDER BY c DESC,a,b
sl@0
  1182
  }
sl@0
  1183
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
  1184
do_test selectA-3.81 {
sl@0
  1185
  execsql {
sl@0
  1186
    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2
sl@0
  1187
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
  1188
  }
sl@0
  1189
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
  1190
do_test selectA-3.82 {
sl@0
  1191
  execsql {
sl@0
  1192
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1193
    ORDER BY a,b,c
sl@0
  1194
  }
sl@0
  1195
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
  1196
do_test selectA-3.83 {
sl@0
  1197
  execsql {
sl@0
  1198
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1199
    ORDER BY a DESC,b,c
sl@0
  1200
  }
sl@0
  1201
} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}
sl@0
  1202
do_test selectA-3.84 {
sl@0
  1203
  execsql {
sl@0
  1204
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1205
    ORDER BY a,c,b
sl@0
  1206
  }
sl@0
  1207
} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}
sl@0
  1208
do_test selectA-3.85 {
sl@0
  1209
  execsql {
sl@0
  1210
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1211
    ORDER BY b,a,c
sl@0
  1212
  }
sl@0
  1213
} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}
sl@0
  1214
do_test selectA-3.86 {
sl@0
  1215
  execsql {
sl@0
  1216
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1217
    ORDER BY b COLLATE NOCASE,a,c
sl@0
  1218
  }
sl@0
  1219
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
  1220
do_test selectA-3.87 {
sl@0
  1221
  execsql {
sl@0
  1222
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1223
    ORDER BY y COLLATE NOCASE DESC,x,z
sl@0
  1224
  }
sl@0
  1225
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
  1226
do_test selectA-3.88 {
sl@0
  1227
  execsql {
sl@0
  1228
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1229
    ORDER BY c,b,a
sl@0
  1230
  }
sl@0
  1231
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
  1232
do_test selectA-3.89 {
sl@0
  1233
  execsql {
sl@0
  1234
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1235
    ORDER BY c,a,b
sl@0
  1236
  }
sl@0
  1237
} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}
sl@0
  1238
do_test selectA-3.90 {
sl@0
  1239
  execsql {
sl@0
  1240
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1241
    ORDER BY c DESC,a,b
sl@0
  1242
  }
sl@0
  1243
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
  1244
do_test selectA-3.91 {
sl@0
  1245
  execsql {
sl@0
  1246
    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3
sl@0
  1247
    ORDER BY c COLLATE BINARY DESC,a,b
sl@0
  1248
  }
sl@0
  1249
} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}
sl@0
  1250
do_test selectA-3.92 {
sl@0
  1251
  execsql {
sl@0
  1252
    SELECT x,y,z FROM t2
sl@0
  1253
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1254
    EXCEPT SELECT c,b,a FROM t1
sl@0
  1255
    UNION SELECT a,b,c FROM t3
sl@0
  1256
    INTERSECT SELECT a,b,c FROM t3
sl@0
  1257
    EXCEPT SELECT c,b,a FROM t1
sl@0
  1258
    UNION SELECT a,b,c FROM t3
sl@0
  1259
    ORDER BY y COLLATE NOCASE DESC,x,z
sl@0
  1260
  }
sl@0
  1261
} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}
sl@0
  1262
do_test selectA-3.93 {
sl@0
  1263
  execsql {
sl@0
  1264
    SELECT upper((SELECT c FROM t1 UNION SELECT z FROM t2 ORDER BY 1));
sl@0
  1265
  }
sl@0
  1266
} {A}
sl@0
  1267
do_test selectA-3.94 {
sl@0
  1268
  execsql {
sl@0
  1269
    SELECT lower((SELECT c FROM t1 UNION ALL SELECT z FROM t2 ORDER BY 1));
sl@0
  1270
  }
sl@0
  1271
} {a}
sl@0
  1272
do_test selectA-3.95 {
sl@0
  1273
  execsql {
sl@0
  1274
    SELECT lower((SELECT c FROM t1 INTERSECT SELECT z FROM t2 ORDER BY 1));
sl@0
  1275
  }
sl@0
  1276
} {{}}
sl@0
  1277
do_test selectA-3.96 {
sl@0
  1278
  execsql {
sl@0
  1279
    SELECT lower((SELECT z FROM t2 EXCEPT SELECT c FROM t1 ORDER BY 1));
sl@0
  1280
  }
sl@0
  1281
} {m}
sl@0
  1282
do_test selectA-3.97 {
sl@0
  1283
  execsql {
sl@0
  1284
    SELECT upper((SELECT x FROM (
sl@0
  1285
      SELECT x,y,z FROM t2
sl@0
  1286
      INTERSECT SELECT a,b,c FROM t3
sl@0
  1287
      EXCEPT SELECT c,b,a FROM t1
sl@0
  1288
      UNION SELECT a,b,c FROM t3
sl@0
  1289
      INTERSECT SELECT a,b,c FROM t3
sl@0
  1290
      EXCEPT SELECT c,b,a FROM t1
sl@0
  1291
      UNION SELECT a,b,c FROM t3
sl@0
  1292
      ORDER BY y COLLATE NOCASE DESC,x,z)))
sl@0
  1293
  }
sl@0
  1294
} {MAD}
sl@0
  1295
sl@0
  1296
finish_test