SQLite

Check-in [b9866005]
Login

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

Overview
Comment:Do not invoke sqlite3ExprAffinity() after a syntax error that might have left the tree in an inconsistent state. See also [e8a1515b44380cc5] and forum post 7e484e225c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b986600520696b0c91c4ccc6aff1b698391b4bcaf8a3ea436be1967883faa2fe
User & Date: drh 2021-05-22 11:23:20
References
2021-05-24
00:17
Additional defenses (above and beyond [b986600520696b0c]) to prevent an invalid subquery from causing problems downstream. If an error is found while analyzing a subquery expression, change the expression to TK_ERROR so inhibit further processing on that expression. dbsqlfuzz cf624b8c0484c66e0f552bf6475e3e3f2c22b24e. (check-in: 0be6b6c9 user: drh tags: trunk)
Context
2021-05-23
17:47
Do not push a WITH clause onto the processing stack if prior errors have occurred. dbsqlfuzz 6b7a144674e215f06ddfeb9042c873d9ee956ac0. (check-in: c2066dde user: drh tags: trunk)
2021-05-22
11:23
Do not invoke sqlite3ExprAffinity() after a syntax error that might have left the tree in an inconsistent state. See also [e8a1515b44380cc5] and forum post 7e484e225c. (check-in: b9866005 user: drh tags: trunk)
11:00
The fix in the previous check-in was only correct if the OOM occurs on the initial allocation. This changes should make it correct for a resize as well. (check-in: 57087ab2 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
      }
    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){
      Expr *pRight = pTerm->pExpr->pRight;
      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
        VdbeCoverage(v);
      }
      if( pParse->db->mallocFailed==0 ){
        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
      }







|







769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
      }
    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){
      Expr *pRight = pTerm->pExpr->pRight;
      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
        VdbeCoverage(v);
      }
      if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){
        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
      }

Changes to test/window1.test.

2155
2156
2157
2158
2159
2160
2161










2162
reset_db
do_catchsql_test 68.0 {
  CREATE TABLE t1(a,b);
  INSERT INTO t1(a,b) VALUES(0,0),(1,1),(2,4),(3,9),(4,99);
  SELECT rowid, a, b, sum(a)OVER() FROM t1 ORDER BY count(b);
} {1 {misuse of aggregate: count()}}











finish_test







>
>
>
>
>
>
>
>
>
>

2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
reset_db
do_catchsql_test 68.0 {
  CREATE TABLE t1(a,b);
  INSERT INTO t1(a,b) VALUES(0,0),(1,1),(2,4),(3,9),(4,99);
  SELECT rowid, a, b, sum(a)OVER() FROM t1 ORDER BY count(b);
} {1 {misuse of aggregate: count()}}

# 2021-05-22
# Forum https://sqlite.org/forum/forumpost/7e484e225c
#
reset_db
do_catchsql_test 69.0 {
  CREATE TABLE t1(a,b);
  CREATE INDEX t1ba ON t1(b,a);
  SELECT * FROM t1 WHERE b = (SELECT b FROM t1 ORDER BY lead(b) OVER () AND SUM(a));
} {1 {misuse of aggregate: SUM()}}

finish_test