Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix for ticket #102: Honor the ORDER BY clause in subqueries. (CVS 677) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7e918c8b0df5120e3630811f164defb8 |
User & Date: | drh 2002-07-15 18:55:25.000 |
Context
2002-07-15
| ||
20:58 | Fix a syntax error in the tclsqlite.c file. (CVS 678) (check-in: 47997d7f3a user: drh tags: trunk) | |
18:55 | Fix for ticket #102: Honor the ORDER BY clause in subqueries. (CVS 677) (check-in: 7e918c8b0d user: drh tags: trunk) | |
2002-07-13
| ||
17:33 | Fix for ticket #64: Better error reporting in the shell. (CVS 676) (check-in: e1842e04c4 user: drh tags: trunk) | |
Changes
Changes to src/parse.y.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** ** @(#) $Id: parse.y,v 1.79 2002/07/15 18:55:25 drh Exp $ */ %token_prefix TK_ %token_type {Token} %default_type {Token} %extra_argument {Parse *pParse} %syntax_error { sqliteSetString(&pParse->zErrMsg,"syntax error",0); |
︙ | ︙ | |||
342 343 344 345 346 347 348 | if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; } else { sqliteIdListDelete(U); } } } seltablist(A) ::= stl_prefix(X) LP select(S) RP as(Z) on_opt(N) using_opt(U). { A = sqliteSrcListAppend(X,0); A->a[A->nSrc-1].pSelect = S; | < < < < | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; } else { sqliteIdListDelete(U); } } } seltablist(A) ::= stl_prefix(X) LP select(S) RP as(Z) on_opt(N) using_opt(U). { A = sqliteSrcListAppend(X,0); A->a[A->nSrc-1].pSelect = S; if( Z.n ) sqliteSrcListAddAlias(A,&Z); if( N ){ if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; } else { sqliteExprDelete(N); } } if( U ){ if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; } |
︙ | ︙ |
Changes to test/subselect.test.
︙ | ︙ | |||
8 9 10 11 12 13 14 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing SELECT statements that are part of # expressions. # | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing SELECT statements that are part of # expressions. # # $Id: subselect.test,v 1.7 2002/07/15 18:55:26 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Basic sanity checking. Try a simple subselect. # do_test subselect-1.1 { |
︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 | } } {1} do_test subselect-2.3 { execsql { SELECT 2 IN (SELECT a FROM t1 ORDER BY a DESC); } } {0} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | } } {1} do_test subselect-2.3 { execsql { SELECT 2 IN (SELECT a FROM t1 ORDER BY a DESC); } } {0} # Verify that the ORDER BY clause is honored in a subquery. # do_test subselect-3.1 { execsql { CREATE TABLE t3(x int); INSERT INTO t3 SELECT a FROM t1 UNION ALL SELECT b FROM t1; SELECT * FROM t3 ORDER BY x; } } {1 2 3 4 5 6} do_test subselect-3.2 { execsql { SELECT sum(x) FROM (SELECT x FROM t3 ORDER BY x LIMIT 2); } } {3} do_test subselect-3.3 { execsql { SELECT sum(x) FROM (SELECT x FROM t3 ORDER BY x DESC LIMIT 2); } } {11} do_test subselect-3.4 { execsql { SELECT (SELECT x FROM t3 ORDER BY x); } } {1} do_test subselect-3.5 { execsql { SELECT (SELECT x FROM t3 ORDER BY x DESC); } } {6} do_test subselect-3.6 { execsql { SELECT (SELECT x FROM t3 ORDER BY x LIMIT 1); } } {1} do_test subselect-3.7 { execsql { SELECT (SELECT x FROM t3 ORDER BY x DESC LIMIT 1); } } {6} do_test subselect-3.8 { execsql { SELECT (SELECT x FROM t3 ORDER BY x LIMIT 1 OFFSET 2); } } {3} do_test subselect-3.9 { execsql { SELECT (SELECT x FROM t3 ORDER BY x DESC LIMIT 1 OFFSET 2); } } {4} finish_test |