SQLite

Check-in [101f7dea]
Login

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

Overview
Comment:Apply the correct affinity transformations when pulling values off of the sorter index used for GROUP BY. Ticket [e0c2ad1aa8a9c691]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 101f7dea75a203f1f3aa422a607ef701eb0901ba4d5e8d1075cd350454a61956
User & Date: drh 2020-03-10 11:50:43
Context
2020-03-10
13:35
Make a copy of the expression that defines a value of a generated column before sending it to the code generator routines. (check-in: 03d201c0 user: drh tags: trunk)
11:50
Apply the correct affinity transformations when pulling values off of the sorter index used for GROUP BY. Ticket [e0c2ad1aa8a9c691] (check-in: 101f7dea user: drh tags: trunk)
02:57
The sqlite3ExprCodeFactorable() routine should make a copy of non-factorable expressions, as they might be coming from a DEFAULT or generated column in a table constraint. (check-in: a2d6f108 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

3787
3788
3789
3790
3791
3792
3793

3794
3795



3796
3797
3798
3799
3800
3801
3802
    case TK_AGG_COLUMN: {
      AggInfo *pAggInfo = pExpr->pAggInfo;
      struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
      if( !pAggInfo->directMode ){
        assert( pCol->iMem>0 );
        return pCol->iMem;
      }else if( pAggInfo->useSortingIdx ){

        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,
                              pCol->iSorterColumn, target);



        return target;
      }
      /* Otherwise, fall thru into the TK_COLUMN case */
    }
    case TK_COLUMN: {
      int iTab = pExpr->iTable;
      int iReg;







>


>
>
>







3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
    case TK_AGG_COLUMN: {
      AggInfo *pAggInfo = pExpr->pAggInfo;
      struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
      if( !pAggInfo->directMode ){
        assert( pCol->iMem>0 );
        return pCol->iMem;
      }else if( pAggInfo->useSortingIdx ){
        Table *pTab = pCol->pTab;
        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,
                              pCol->iSorterColumn, target);
        if( ALWAYS(pTab) && pCol->iColumn>=0 ){
          sqlite3ColumnDefault(v, pTab, pCol->iColumn, target);
        }
        return target;
      }
      /* Otherwise, fall thru into the TK_COLUMN case */
    }
    case TK_COLUMN: {
      int iTab = pExpr->iTable;
      int iReg;

Changes to test/select3.test.

301
302
303
304
305
306
307








308
309
     INSERT INTO t1(c0, c1) VALUES (0, $x), (0, 0);
     UPDATE t1 SET c0 = NULL;
     UPDATE OR REPLACE t1 SET c1 = 1;
     SELECT DISTINCT * FROM t1 WHERE (t1.c0 IS NULL);
     PRAGMA integrity_check;
  } {{} 1.0 ok}
}









finish_test







>
>
>
>
>
>
>
>


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
     INSERT INTO t1(c0, c1) VALUES (0, $x), (0, 0);
     UPDATE t1 SET c0 = NULL;
     UPDATE OR REPLACE t1 SET c1 = 1;
     SELECT DISTINCT * FROM t1 WHERE (t1.c0 IS NULL);
     PRAGMA integrity_check;
  } {{} 1.0 ok}
}

# 2020-03-10 ticket e0c2ad1aa8a9c691
reset_db
do_execsql_test select3-9.100 {
  CREATE TABLE t0(c0 REAL, c1 REAL GENERATED ALWAYS AS (c0));
  INSERT INTO t0(c0) VALUES (1);
  SELECT * FROM t0 GROUP BY c0;
} {1.0 1.0}

finish_test