os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2339.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 May 6
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
#
sl@0
    12
# $Id: tkt2339.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
sl@0
    13
#
sl@0
    14
sl@0
    15
set testdir [file dirname $argv0]
sl@0
    16
source $testdir/tester.tcl
sl@0
    17
sl@0
    18
ifcapable !subquery||!compound {
sl@0
    19
  finish_test
sl@0
    20
  return
sl@0
    21
}
sl@0
    22
sl@0
    23
do_test tkt2339.1 {
sl@0
    24
  execsql {
sl@0
    25
    create table t1(num int);
sl@0
    26
    insert into t1 values (1);
sl@0
    27
    insert into t1 values (2);
sl@0
    28
    insert into t1 values (3);
sl@0
    29
    insert into t1 values (4);
sl@0
    30
    
sl@0
    31
    create table t2(num int);
sl@0
    32
    insert into t2 values (11);
sl@0
    33
    insert into t2 values (12);
sl@0
    34
    insert into t2 values (13);
sl@0
    35
    insert into t2 values (14);
sl@0
    36
    
sl@0
    37
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
sl@0
    38
    UNION
sl@0
    39
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
sl@0
    40
  }
sl@0
    41
} {3 4 13 14}
sl@0
    42
do_test tkt2339.2 {
sl@0
    43
  execsql {
sl@0
    44
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
sl@0
    45
    UNION ALL
sl@0
    46
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
sl@0
    47
  }
sl@0
    48
} {4 3 14 13}
sl@0
    49
do_test tkt2339.3 {
sl@0
    50
  execsql {
sl@0
    51
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC)
sl@0
    52
    UNION ALL
sl@0
    53
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
sl@0
    54
  }
sl@0
    55
} {4 3 2 1 14 13}
sl@0
    56
do_test tkt2339.4 {
sl@0
    57
  execsql {
sl@0
    58
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
sl@0
    59
    UNION ALL
sl@0
    60
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)
sl@0
    61
  }
sl@0
    62
} {4 3 14 13 12 11}
sl@0
    63
do_test tkt2339.5 {
sl@0
    64
  execsql {
sl@0
    65
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
sl@0
    66
    UNION
sl@0
    67
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)
sl@0
    68
  }
sl@0
    69
} {3 4 11 12 13 14}
sl@0
    70
do_test tkt2339.6 {
sl@0
    71
  execsql {
sl@0
    72
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
sl@0
    73
    EXCEPT
sl@0
    74
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)
sl@0
    75
  }
sl@0
    76
} {3 4}
sl@0
    77
do_test tkt2339.7 {
sl@0
    78
  execsql {
sl@0
    79
    SELECT * FROM (SELECT * FROM t1 LIMIT 2)
sl@0
    80
    UNION
sl@0
    81
    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)
sl@0
    82
  }
sl@0
    83
} {1 2 13 14}
sl@0
    84
do_test tkt2339.8 {
sl@0
    85
  execsql {
sl@0
    86
    SELECT * FROM (SELECT * FROM t1 LIMIT 2)
sl@0
    87
    UNION
sl@0
    88
    SELECT * FROM (SELECT * FROM t2 LIMIT 2)
sl@0
    89
  }
sl@0
    90
} {1 2 11 12}
sl@0
    91
do_test tkt2339.9 {
sl@0
    92
  execsql {
sl@0
    93
    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)
sl@0
    94
    UNION
sl@0
    95
    SELECT * FROM (SELECT * FROM t2 LIMIT 2)
sl@0
    96
  }
sl@0
    97
} {3 4 11 12}
sl@0
    98
sl@0
    99
sl@0
   100
finish_test