SQLite

Check-in [fcb669cf]
Login

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

Overview
Comment:Do not convert an expression node that is already TK_REGISTER into a new TK_REGISTER. This is a follow-up to [663f5dd32d9db832] that fixes a bug discovered by dbsqlfuzz.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fcb669cfaa8a59ca710504d5aaa1936f65a6da8ff13473ad84458f97a6fd1f49
User & Date: drh 2024-06-28 17:14:00
Context
2024-06-28
18:07
Additional steps to make sure calls to sqlite3ExprToRegister() are sane. (check-in: 1c42d717 user: drh tags: trunk)
17:14
Do not convert an expression node that is already TK_REGISTER into a new TK_REGISTER. This is a follow-up to [663f5dd32d9db832] that fixes a bug discovered by dbsqlfuzz. (check-in: fcb669cf user: drh tags: trunk)
2024-06-24
18:06
Fix an incorrect tcl comment that appeared in many fts5 test files. (check-in: d07085e2 user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/select.c.

8332
8333
8334
8335
8336
8337
8338
8339



8340
8341
8342
8343
8344
8345
8346
          pAggInfo->directMode = 1;
          sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);
        }

        if( iOrderByCol ){
          Expr *pX = p->pEList->a[iOrderByCol-1].pExpr;
          Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX);
          if( ALWAYS(pBase!=0) && pBase->op!=TK_AGG_COLUMN ){



            sqlite3ExprToRegister(pX, iAMem+j);
          }
        }
      }
      sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,
                          (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);
      addr1 = sqlite3VdbeCurrentAddr(v);







|
>
>
>







8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
          pAggInfo->directMode = 1;
          sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);
        }

        if( iOrderByCol ){
          Expr *pX = p->pEList->a[iOrderByCol-1].pExpr;
          Expr *pBase = sqlite3ExprSkipCollateAndLikely(pX);
          if( ALWAYS(pBase!=0)
           && pBase->op!=TK_AGG_COLUMN
           && pBase->op!=TK_REGISTER
          ){
            sqlite3ExprToRegister(pX, iAMem+j);
          }
        }
      }
      sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,
                          (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);
      addr1 = sqlite3VdbeCurrentAddr(v);

Changes to test/distinct2.test.

357
358
359
360
361
362
363


















364
365
} NULL

do_execsql_test 5070 {
  DROP VIEW v4;
  CREATE VIEW  v4(e) AS SELECT (SELECT unlikely(t2.c COLLATE nocase) FROM t0, t1 GROUP BY 1) FROM t2;
  SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1;
} NULL



















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
} NULL

do_execsql_test 5070 {
  DROP VIEW v4;
  CREATE VIEW  v4(e) AS SELECT (SELECT unlikely(t2.c COLLATE nocase) FROM t0, t1 GROUP BY 1) FROM t2;
  SELECT v4.e FROM t3 LEFT JOIN v4 ON true GROUP BY 1;
} NULL

# 2024-06-28 dbsqlfuzz 46343912848a603e32c6072cae792eb056bac897
# Do not call sqlite3ExprToRegister() on an expression that is already
# a register.
#
do_execsql_test 5080 {
  CREATE TABLE dual(dummy TEXT);
  INSERT INTO dual VALUES('X');
  SELECT 11 = (
                SELECT b
                  FROM (
                         SELECT a AS b
                           FROM dual
                           LEFT JOIN (SELECT 22 AS a FROM dual)
                       )
                 GROUP BY b, b
              );
} 0

finish_test