/ Check-in [9c8b97ef]
Login

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

Overview
Comment:Fix a crash in flattenSubquery(). (CVS 5388)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9c8b97ef593c17740640a01a7338164d7fbe070e
User & Date: danielk1977 2008-07-10 17:59:12
Context
2008-07-10
18:13
Enhancements to the testing logic for malloc and mutex. Only permit one of MEMSYS3/5 to be compiled-in at a time. Omit the SQLITE_CONFIG_MEMSYS3/5 configuration options. (CVS 5389) check-in: ed8b2525 user: drh tags: trunk
17:59
Fix a crash in flattenSubquery(). (CVS 5388) check-in: 9c8b97ef user: danielk1977 tags: trunk
17:52
Add the SQLITE_OPEN_NOMUTEX flag. Used for opening connections that are not protected by an internal mutex. (CVS 5387) check-in: 7e58b787 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3057
3058
3059
3060
3061
3062
3063
3064


3065
3066
3067
3068
3069
3070
3071
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.453 2008/07/10 00:32:42 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
  */
  if( pSub->pPrior ){
    if( p->pPrior || isAgg || p->isDistinct || pSrc->nSrc!=1 ){
      return 0;
    }
    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
      if( pSub1->isAgg || pSub1->isDistinct 
       || (pSub1->pPrior && pSub1->op!=TK_ALL) ){


        return 0;
      }
    }

    /* Restriction 18. */
    if( p->pOrderBy ){
      int ii;







|







 







|
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.454 2008/07/10 17:59:12 danielk1977 Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
  */
  if( pSub->pPrior ){
    if( p->pPrior || isAgg || p->isDistinct || pSrc->nSrc!=1 ){
      return 0;
    }
    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){
      if( pSub1->isAgg || pSub1->isDistinct 
       || (pSub1->pPrior && pSub1->op!=TK_ALL) 
       || !pSub1->pSrc || pSub1->pSrc->nSrc!=1
      ){
        return 0;
      }
    }

    /* Restriction 18. */
    if( p->pOrderBy ){
      int ii;

Changes to test/selectB.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
359
360
361
362
363
364
365






366
367
368
369
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. 
#
# $Id: selectB.test,v 1.6 2008/07/08 17:43:57 danielk1977 Exp $

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

proc test_transform {testname sql1 sql2 results} {
  set ::vdbe1 [list]
  set ::vdbe2 [list]
................................................................................
  } {0 1}

  do_test selectB-$ii.21 {
    execsql {
      SELECT * FROM (SELECT * FROM t1 UNION ALL SELECT * FROM t2) ORDER BY a+b
    }
  } {2 4 6 3 6 9 8 10 12 12 15 18 14 16 18 21 24 27}






}

finish_test








|







 







>
>
>
>
>
>




6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. 
#
# $Id: selectB.test,v 1.7 2008/07/10 17:59:12 danielk1977 Exp $

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

proc test_transform {testname sql1 sql2 results} {
  set ::vdbe1 [list]
  set ::vdbe2 [list]
................................................................................
  } {0 1}

  do_test selectB-$ii.21 {
    execsql {
      SELECT * FROM (SELECT * FROM t1 UNION ALL SELECT * FROM t2) ORDER BY a+b
    }
  } {2 4 6 3 6 9 8 10 12 12 15 18 14 16 18 21 24 27}

  do_test selectB-$ii.21 {
    execsql {
      SELECT * FROM (SELECT 345 UNION ALL SELECT d FROM t2) ORDER BY 1;
    }
  } {3 12 21 345}
}

finish_test