/ Check-in [68557115]
Login

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

Overview
Comment:Reinsert an SCopy operation that was removed in (5523) because coverage testing indicated that it was dead code. Ticket #3324 shows that the code was not as dead as we thought it was. (CVS 5578)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6855711595b58d4b6fbaf9480720b788904d0e2d
User & Date: drh 2008-08-21 14:15:59
Context
2008-08-21
14:24
Add test cases to verify that ticket #3314 has been fixed. (CVS 5579) check-in: b46267ff user: drh tags: trunk
14:15
Reinsert an SCopy operation that was removed in (5523) because coverage testing indicated that it was dead code. Ticket #3324 shows that the code was not as dead as we thought it was. (CVS 5578) check-in: 68557115 user: drh tags: trunk
12:32
Patch to mkfunction to try and detect miscompiles. Add an unimportant assert back to pcache.c. (CVS 5577) check-in: a2f375ff user: drh 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
....
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778

3779
3780
3781


3782
3783
3784
3785
3786
3787
3788
3789

3790
3791
3792
3793
3794
3795
3796
**    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.466 2008/08/20 16:35:10 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0);
        sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx,regBase+nGroupBy);
        j = nGroupBy+1;
        for(i=0; i<sAggInfo.nColumn; i++){
          struct AggInfo_col *pCol = &sAggInfo.aCol[i];
          if( pCol->iSorterColumn>=j ){
            int r1 = j + regBase;
#ifndef NDEBUG
            int r2 = 
#endif

                     sqlite3ExprCodeGetColumn(pParse, 
                               pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
            j++;



            /* sAggInfo.aCol[] only contains one entry per column.  So
            ** The reference to pCol->iColumn,pCol->iTable must have been
            ** the first reference to that column.  Hence, 
            ** sqliteExprCodeGetColumn is guaranteed to put the result in
            ** the column requested. 
            */
            assert( r1==r2 );

          }
        }
        regRecord = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);
        sqlite3VdbeAddOp2(v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord);
        sqlite3ReleaseTempReg(pParse, regRecord);
        sqlite3ReleaseTempRange(pParse, regBase, nCol);







|







 







<
|
<
>
|

<
>
>
|
<
<
<
<
<
<
<
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
3769
3770
3771
3772
3773
3774
3775

3776

3777
3778
3779

3780
3781
3782







3783
3784
3785
3786
3787
3788
3789
3790
**    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.467 2008/08/21 14:15:59 drh Exp $
*/
#include "sqliteInt.h"


/*
** Delete all the content of a Select structure but do not deallocate
** the select structure itself.
................................................................................
        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0);
        sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx,regBase+nGroupBy);
        j = nGroupBy+1;
        for(i=0; i<sAggInfo.nColumn; i++){
          struct AggInfo_col *pCol = &sAggInfo.aCol[i];
          if( pCol->iSorterColumn>=j ){
            int r1 = j + regBase;

            int r2;


            r2 = sqlite3ExprCodeGetColumn(pParse, 
                               pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);

            if( r1!=r2 ){
              sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
            }







            j++;
          }
        }
        regRecord = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);
        sqlite3VdbeAddOp2(v, OP_IdxInsert, sAggInfo.sortingIdx, regRecord);
        sqlite3ReleaseTempReg(pParse, regRecord);
        sqlite3ReleaseTempRange(pParse, regBase, nCol);

Changes to test/select5.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
187
188
189
190
191
192
193
194
195
196
197
198
199

























































200
#    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 aggregate functions and the
# GROUP BY and HAVING clauses of SELECT statements.
#
# $Id: select5.test,v 1.19 2008/08/20 16:35:10 drh Exp $

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

# Build some test data
#
execsql {
................................................................................
    INSERT INTO t4 VALUES(5,NULL,NULL);
    INSERT INTO t4 VALUES(5,NULL,NULL);
    INSERT INTO t4 VALUES(6,7,8);
    SELECT max(x), count(x), y, z FROM t4 GROUP BY y, z ORDER BY 1
  }
} {1 1 2 {} 2 1 3 {} 3 1 {} 5 4 2 {} 6 5 2 {} {} 6 1 7 8}

do_test select5.7.2 {
  execsql {
    SELECT count(*), count(x) as cnt FROM t4 GROUP BY y ORDER BY cnt;
  }
} {1 1 1 1 1 1 5 5}
 

























































finish_test







|







 







|




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

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#    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 aggregate functions and the
# GROUP BY and HAVING clauses of SELECT statements.
#
# $Id: select5.test,v 1.20 2008/08/21 14:15:59 drh Exp $

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

# Build some test data
#
execsql {
................................................................................
    INSERT INTO t4 VALUES(5,NULL,NULL);
    INSERT INTO t4 VALUES(5,NULL,NULL);
    INSERT INTO t4 VALUES(6,7,8);
    SELECT max(x), count(x), y, z FROM t4 GROUP BY y, z ORDER BY 1
  }
} {1 1 2 {} 2 1 3 {} 3 1 {} 5 4 2 {} 6 5 2 {} {} 6 1 7 8}

do_test select5-7.2 {
  execsql {
    SELECT count(*), count(x) as cnt FROM t4 GROUP BY y ORDER BY cnt;
  }
} {1 1 1 1 1 1 5 5}

# See ticket #3324.
#
do_test select5-8.1 {
  execsql {
    CREATE TABLE t8a(a,b);
    CREATE TABLE t8b(x);
    INSERT INTO t8a VALUES('one', 1);
    INSERT INTO t8a VALUES('one', 2);
    INSERT INTO t8a VALUES('two', 3);
    INSERT INTO t8a VALUES('one', NULL);
    INSERT INTO t8b(rowid,x) VALUES(1,111);
    INSERT INTO t8b(rowid,x) VALUES(2,222);
    INSERT INTO t8b(rowid,x) VALUES(3,333);
    SELECT a, count(b) FROM t8a, t8b WHERE b=t8b.rowid GROUP BY a ORDER BY a;
  }
} {one 2 two 1}
do_test select5-8.2 {
  execsql {
    SELECT a, count(b) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a;
  }
} {one 2 two 1}
do_test select5-8.3 {
  execsql {
    SELECT t8a.a, count(t8a.b) FROM t8a, t8b WHERE t8a.b=t8b.rowid
     GROUP BY 1 ORDER BY 1;
  }
} {one 2 two 1}
do_test select5-8.4 {
  execsql {
    SELECT a, count(*) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a;
  }
} {one 2 two 1}
do_test select5-8.5 {
  execsql {
    SELECT a, count(b) FROM t8a, t8b WHERE b<x GROUP BY a ORDER BY a;
  }
} {one 6 two 3}
do_test select5-8.6 {
  execsql {
    SELECT a, count(t8a.b) FROM t8a, t8b WHERE b=t8b.rowid 
     GROUP BY a ORDER BY 2;
  }
} {two 1 one 2}
do_test select5-8.7 {
  execsql {
    SELECT a, count(b) FROM t8a, t8b GROUP BY a ORDER BY 2;
  }
} {two 3 one 6}
do_test select5-8.8 {
  execsql {
    SELECT a, count(*) FROM t8a, t8b GROUP BY a ORDER BY 2;
  }
} {two 3 one 9}



 
finish_test