SQLite

Check-in [a67da9dd2f]
Login

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

Overview
Comment:Add test cases for ticket #3378 and #3381. Add a temporary hack to get those to problems fixed. The hack causes failures in alias.test, but those are much less serious than the aforementioned tickets. This is a stop-gap until we can figure out a proper fix. (CVS 5711)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a67da9dd2ff6acc163de4ce2b836b03e3f159a88
User & Date: drh 2008-09-16 18:02:47.000
Context
2008-09-17
00:13
Fix for tickets #3378 and #3381 that preserves the aliasing optimization. And yet, this fix feels uncomfortable. Seeking an alternative... (CVS 5712) (check-in: f8b759f197 user: drh tags: trunk)
2008-09-16
18:02
Add test cases for ticket #3378 and #3381. Add a temporary hack to get those to problems fixed. The hack causes failures in alias.test, but those are much less serious than the aforementioned tickets. This is a stop-gap until we can figure out a proper fix. (CVS 5711) (check-in: a67da9dd2f user: drh tags: trunk)
15:55
Initialize variable pKeyDup in multiSelectOrderBy(). Technically it doesn't need to be initialized, but the reasoning required to come to that conclusion is too complicated for some automated systems. So it is initialized to keep some compilers happy. Ticket #3382. (CVS 5710) (check-in: bd58be6ecf user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.392 2008/08/29 02:14:03 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Return the 'affinity' of the expression pExpr if any.
**







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.393 2008/09/16 18:02:47 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** Return the 'affinity' of the expression pExpr if any.
**
2460
2461
2462
2463
2464
2465
2466

2467
2468
2469
2470
2471


2472
2473
2474
2475
2476
2477
2478
){
  struct ExprList_item *pItem;
  int i, n;
  assert( pList!=0 );
  assert( target>0 );
  n = pList->nExpr;
  for(pItem=pList->a, i=0; i<n; i++, pItem++){

    if( pItem->iAlias ){
      int iReg = codeAlias(pParse, pItem->iAlias, pItem->pExpr);
      Vdbe *v = sqlite3GetVdbe(pParse);
      sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target+i);
    }else{


      sqlite3ExprCode(pParse, pItem->pExpr, target+i);
    }
    if( doHardCopy ) sqlite3ExprHardCopy(pParse, target, n);
  }
  return n;
}








>




|
>
>







2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
){
  struct ExprList_item *pItem;
  int i, n;
  assert( pList!=0 );
  assert( target>0 );
  n = pList->nExpr;
  for(pItem=pList->a, i=0; i<n; i++, pItem++){
#if 0  /* Remove temporarily for tickets #3378 and #3381 */
    if( pItem->iAlias ){
      int iReg = codeAlias(pParse, pItem->iAlias, pItem->pExpr);
      Vdbe *v = sqlite3GetVdbe(pParse);
      sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target+i);
    }else
#endif
    {
      sqlite3ExprCode(pParse, pItem->pExpr, target+i);
    }
    if( doHardCopy ) sqlite3ExprHardCopy(pParse, target, n);
  }
  return n;
}

Changes to test/selectC.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
# 2008 September 16
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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: selectC.test,v 1.1 2008/09/16 15:09:54 drh Exp $

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


do_test selectC-1.1 {
  execsql {
    CREATE TABLE t1(a, b, c);
    INSERT INTO t1 VALUES(1,'aaa','bbb');
    INSERT INTO t1 SELECT * FROM t1;
    INSERT INTO t1 VALUES(2,'ccc','ddd');













|




>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 2008 September 16
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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: selectC.test,v 1.2 2008/09/16 18:02:47 drh Exp $

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

# Ticket #
do_test selectC-1.1 {
  execsql {
    CREATE TABLE t1(a, b, c);
    INSERT INTO t1 VALUES(1,'aaa','bbb');
    INSERT INTO t1 SELECT * FROM t1;
    INSERT INTO t1 VALUES(2,'ccc','ddd');

65
66
67
68
69
70
71






72










































73
do_test selectC-1.7 {
  execsql {
    SELECT DISTINCT a AS x, b||c AS y
      FROM t1
     WHERE +y='aaabbb'
  }
} {1 aaabbb}

















































finish_test







>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
do_test selectC-1.7 {
  execsql {
    SELECT DISTINCT a AS x, b||c AS y
      FROM t1
     WHERE +y='aaabbb'
  }
} {1 aaabbb}
do_test selectC-1.8 {
  execsql {
    SELECT a AS x, b||c AS y
      FROM t1
     GROUP BY x, y
    HAVING y='aaabbb'
  }
} {1 aaabbb}
do_test selectC-1.9 {
  execsql {
    SELECT a AS x, b||c AS y
      FROM t1
     GROUP BY x, y
    HAVING b||c='aaabbb'
  }
} {1 aaabbb}
do_test selectC-1.10 {
  execsql {
    SELECT a AS x, b||c AS y
      FROM t1
     WHERE y='aaabbb'
     GROUP BY x, y
  }
} {1 aaabbb}
do_test selectC-1.11 {
  execsql {
    SELECT a AS x, b||c AS y
      FROM t1
     WHERE b||c='aaabbb'
     GROUP BY x, y
  }
} {1 aaabbb}
do_test selectC-1.12 {
  execsql {
    SELECT DISTINCT upper(b) AS x
      FROM t1
     ORDER BY x
  }
} {AAA CCC}
do_test selectC-1.13 {
  execsql {
    SELECT upper(b) AS x
      FROM t1
     GROUP BY x
     ORDER BY x
  }
} {AAA CCC}


finish_test