SQLite

Check-in [ffe23af7]
Login

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

Overview
Comment:When the left table of a RIGHT JOIN is used inside an aggregate function and the left table employs an index on expressions, then make sure the expressions evaluate to NULL for the cases where the left table should be NULL. Fix for forum post 9b491e1deb.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ffe23af73fcb324df988a00be343654ce7078b7208647c4eb779d666b8297e7c
User & Date: drh 2023-03-25 23:52:05
Context
2023-03-26
11:54
Disable factoring of constant values during ANALYZE. This is a temporary fix for forum post 07de5f6216. The register allocation logic in ANALYZE needs to be completely refactored, but that will take longer. This check-in will serve to resolve the issue until a better fix can be devised. (check-in: c3967d12 user: drh tags: trunk)
2023-03-25
23:56
When the left table of a RIGHT JOIN is used inside an aggregate function and the left table employs an index on expressions, then make sure the expressions evaluate to NULL for the cases where the left table should be NULL. (check-in: c51df77e user: drh tags: branch-3.41)
23:52
When the left table of a RIGHT JOIN is used inside an aggregate function and the left table employs an index on expressions, then make sure the expressions evaluate to NULL for the cases where the left table should be NULL. Fix for forum post 9b491e1deb. (check-in: ffe23af7 user: drh tags: trunk)
23:40
Add usage detection to the NULL value generator for the left table of a RIGHT JOIN inside of an aggregate. (Closed-Leaf check-in: 4d05a009 user: drh tags: rightjoin-agg-idxexpr)
22:37
When reading sqlite_stat4 data during query planning, be sure to expand zeroblobs prior to running comparisons. Fix for the issue identified by forum post 5275207102. (check-in: 5c8dd8df user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
4218
4219
4220
4221
4222
4223
4224
4225












4226
4227
4228
4229
4230
4231
4232
    op = pExpr->op;
  }
  switch( op ){
    case TK_AGG_COLUMN: {
      AggInfo *pAggInfo = pExpr->pAggInfo;
      struct AggInfo_col *pCol;
      assert( pAggInfo!=0 );
      assert( pExpr->iAgg>=0 && pExpr->iAgg<pAggInfo->nColumn );












      pCol = &pAggInfo->aCol[pExpr->iAgg];
      if( !pAggInfo->directMode ){
        return AggInfoColumnReg(pAggInfo, pExpr->iAgg);
      }else if( pAggInfo->useSortingIdx ){
        Table *pTab = pCol->pTab;
        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,
                              pCol->iSorterColumn, target);







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







4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
    op = pExpr->op;
  }
  switch( op ){
    case TK_AGG_COLUMN: {
      AggInfo *pAggInfo = pExpr->pAggInfo;
      struct AggInfo_col *pCol;
      assert( pAggInfo!=0 );
      assert( pExpr->iAgg>=0 );
      if( pExpr->iAgg>=pAggInfo->nColumn ){
        /* Happens when the left table of a RIGHT JOIN is null and
        ** is using an expression index */
        sqlite3VdbeAddOp2(v, OP_Null, 0, target);
#ifdef SQLITE_VDBE_COVERAGE
        /* Verify that the OP_Null above is exercised by tests
        ** tag-20230325-2 */
        sqlite3VdbeAddOp2(v, OP_NotNull, target, 1);
        VdbeCoverageNeverTaken(v);
#endif
        break;
      }
      pCol = &pAggInfo->aCol[pExpr->iAgg];
      if( !pAggInfo->directMode ){
        return AggInfoColumnReg(pAggInfo, pExpr->iAgg);
      }else if( pAggInfo->useSortingIdx ){
        Table *pTab = pCol->pTab;
        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,
                              pCol->iSorterColumn, target);