SQLite

Check-in [8fe8e9c460]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix test numbering in tkt2822.test. Ticket #2830. (CVS 4611)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8fe8e9c460e0f8ebc4267de96b0c971cb6370861
User & Date: danielk1977 2007-12-12 04:38:27.000
Context
2007-12-12
12:00
Add a new OP_StackDepth opcode to help detect VDBE stack leaks early, before they cause damage. For diagnostics in ticket #2832. (CVS 4612) (check-in: 3fd6a26753 user: drh tags: trunk)
04:38
Fix test numbering in tkt2822.test. Ticket #2830. (CVS 4611) (check-in: 8fe8e9c460 user: danielk1977 tags: trunk)
2007-12-11
20:04
Fix a comment on the SQLITE_SQL_MAX_LENGTH definition. (CVS 4610) (check-in: 9335c94050 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/tkt2822.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
#***********************************************************************
#
# This file is to test that the issues surrounding expressions in
# ORDER BY clauses on compound SELECT statements raised by ticket
# #2822 have been dealt with.
#
# $Id: tkt2822.test,v 1.1 2007/12/10 18:51:48 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test plan:
#
#   tkt2820-1.* - Simple identifier as ORDER BY expression.
#   tkt2820-2.* - More complex ORDER BY expressions.

do_test tkt2820-1.1 {
  execsql {
    CREATE TABLE t1(a, b, c);
    CREATE TABLE t2(c, b, a);

    INSERT INTO t1 VALUES(1, 2, 3);
    INSERT INTO t2 VALUES(3, 2, 1);
  }
} {}

# If an ORDER BY expression matches two different columns, it is an error.
#
do_test tkt2820-1.2 {
  catchsql {
    SELECT a, b FROM t1 UNION ALL SELECT b, a FROM t2 ORDER BY a;
  }
} {1 {ORDER BY term number 1 is ambiguous}}
do_test tkt2820-1.3 {
  catchsql {
    SELECT a, b, c FROM t2 UNION ALL SELECT c, b, a FROM t1 ORDER BY a;
  }
} {1 {ORDER BY term number 1 is ambiguous}}

# But not if it matches the same column in two or more of the
# compounded SELECT statements.
#
do_test tkt2820-1.4 {
  execsql {
    SELECT a, b, c FROM t2 UNION ALL SELECT a, b, c FROM t1 ORDER BY a;
  }
} {1 2 3 1 2 3}

do_test tkt2820-1.5 {
  execsql {
    SELECT a, b FROM t2 UNION ALL SELECT c, b FROM t1 ORDER BY c;
  }
} {1 2 3 2}

# If a match cannot be found in any SELECT, return an error.
#
do_test tkt2820-1.6 {
  catchsql {
    SELECT * FROM t2 UNION ALL SELECT * FROM t1 ORDER BY d;
  }
} {1 {ORDER BY term number 1 does not match any result column}}


do_test tkt2820-2.1 {
  execsql {
    SELECT a+1, b+1 FROM t1 UNION ALL SELECT a, c FROM t2 ORDER BY a+1;
  }
} {1 3 2 3}
do_test tkt2820-2.2 {
  catchsql {
    SELECT a+1, b+1 FROM t1 UNION ALL SELECT a, c FROM t2 ORDER BY a+2;
  }
} {1 {ORDER BY term number 1 does not match any result column}}
do_test tkt2820-2.3 {
  catchsql {
    SELECT a+1, b+1 FROM t1 UNION ALL SELECT c, a+1 FROM t2 ORDER BY a+1;
  }
} {1 {ORDER BY term number 1 is ambiguous}}

do_test tkt2820-2.4 {
  execsql {
    SELECT t1.a, b+1 FROM t1 UNION ALL SELECT c, a+1 FROM t2 ORDER BY a;
  }
} {1 3 3 2}
do_test tkt2820-2.5 {
  execsql {
    SELECT t1.a, b+1 FROM t1 UNION ALL SELECT c, a+1 FROM t2 ORDER BY t1.a;
  }
} {1 3 3 2}

finish_test








|







|
|

|











|




|








|





|







|






|




|




|





|




|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
#***********************************************************************
#
# This file is to test that the issues surrounding expressions in
# ORDER BY clauses on compound SELECT statements raised by ticket
# #2822 have been dealt with.
#
# $Id: tkt2822.test,v 1.2 2007/12/12 04:38:27 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Test plan:
#
#   tkt2822-1.* - Simple identifier as ORDER BY expression.
#   tkt2822-2.* - More complex ORDER BY expressions.

do_test tkt2822-1.1 {
  execsql {
    CREATE TABLE t1(a, b, c);
    CREATE TABLE t2(c, b, a);

    INSERT INTO t1 VALUES(1, 2, 3);
    INSERT INTO t2 VALUES(3, 2, 1);
  }
} {}

# If an ORDER BY expression matches two different columns, it is an error.
#
do_test tkt2822-1.2 {
  catchsql {
    SELECT a, b FROM t1 UNION ALL SELECT b, a FROM t2 ORDER BY a;
  }
} {1 {ORDER BY term number 1 is ambiguous}}
do_test tkt2822-1.3 {
  catchsql {
    SELECT a, b, c FROM t2 UNION ALL SELECT c, b, a FROM t1 ORDER BY a;
  }
} {1 {ORDER BY term number 1 is ambiguous}}

# But not if it matches the same column in two or more of the
# compounded SELECT statements.
#
do_test tkt2822-1.4 {
  execsql {
    SELECT a, b, c FROM t2 UNION ALL SELECT a, b, c FROM t1 ORDER BY a;
  }
} {1 2 3 1 2 3}

do_test tkt2822-1.5 {
  execsql {
    SELECT a, b FROM t2 UNION ALL SELECT c, b FROM t1 ORDER BY c;
  }
} {1 2 3 2}

# If a match cannot be found in any SELECT, return an error.
#
do_test tkt2822-1.6 {
  catchsql {
    SELECT * FROM t2 UNION ALL SELECT * FROM t1 ORDER BY d;
  }
} {1 {ORDER BY term number 1 does not match any result column}}


do_test tkt2822-2.1 {
  execsql {
    SELECT a+1, b+1 FROM t1 UNION ALL SELECT a, c FROM t2 ORDER BY a+1;
  }
} {1 3 2 3}
do_test tkt2822-2.2 {
  catchsql {
    SELECT a+1, b+1 FROM t1 UNION ALL SELECT a, c FROM t2 ORDER BY a+2;
  }
} {1 {ORDER BY term number 1 does not match any result column}}
do_test tkt2822-2.3 {
  catchsql {
    SELECT a+1, b+1 FROM t1 UNION ALL SELECT c, a+1 FROM t2 ORDER BY a+1;
  }
} {1 {ORDER BY term number 1 is ambiguous}}

do_test tkt2822-2.4 {
  execsql {
    SELECT t1.a, b+1 FROM t1 UNION ALL SELECT c, a+1 FROM t2 ORDER BY a;
  }
} {1 3 3 2}
do_test tkt2822-2.5 {
  execsql {
    SELECT t1.a, b+1 FROM t1 UNION ALL SELECT c, a+1 FROM t2 ORDER BY t1.a;
  }
} {1 3 3 2}

finish_test