/ Check-in [85fd70fe]
Login

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

Overview
Comment:Fix a memory leak that could follow an OOM in the new FILTER code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 85fd70fead834aed16cffbea892b2255b4e10dd677f4dbbb96062d5ff42efdeb
User & Date: dan 2019-07-13 18:27:54
Context
2019-07-14
00:15
Mark an unreachable branch using ALWAYS(). check-in: 0fff105a user: drh tags: trunk
2019-07-13
18:27
Fix a memory leak that could follow an OOM in the new FILTER code. check-in: 85fd70fe user: dan tags: trunk
17:54
Fix a typo in test file window1.test. check-in: 8c80e81d user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

  1738   1738     A = O;
  1739   1739   }
  1740   1740   filter_over(A) ::= filter_clause(F). {
  1741   1741     A = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
  1742   1742     if( A ){
  1743   1743       A->eFrmType = TK_FILTER;
  1744   1744       A->pFilter = F;
         1745  +  }else{
         1746  +    sqlite3ExprDelete(pParse->db, F);
  1745   1747     }
  1746   1748   }
  1747   1749   
  1748   1750   over_clause(A) ::= OVER LP window(Z) RP. {
  1749   1751     A = Z;
  1750   1752     assert( A!=0 );
  1751   1753   }

Added test/filterfault.test.

            1  +# 2018 May 8
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.
           12  +#
           13  +
           14  +set testdir [file dirname $argv0]
           15  +source $testdir/tester.tcl
           16  +set testprefix filterfault
           17  +
           18  +ifcapable !windowfunc {
           19  +  finish_test
           20  +  return
           21  +}
           22  +
           23  +do_execsql_test 1.0 {
           24  +  CREATE TABLE t1(a, b, c, d);
           25  +  INSERT INTO t1 VALUES(1, 2, 3, 4);
           26  +  INSERT INTO t1 VALUES(5, 6, 7, 8);
           27  +  INSERT INTO t1 VALUES(9, 10, 11, 12);
           28  +}
           29  +faultsim_save_and_close
           30  +
           31  +do_faultsim_test 1 -faults oom-t* -prep {
           32  +  faultsim_restore_and_reopen
           33  +} -body {
           34  +  execsql {
           35  +    SELECT sum(a) FILTER (WHERE b<5),
           36  +           count() FILTER (WHERE d!=c) 
           37  +      FROM t1 GROUP BY c ORDER BY 1;
           38  +  }
           39  +} -test {
           40  +  faultsim_test_result {0 {{} 1 {} 1 1 1}}
           41  +}
           42  +
           43  +
           44  +finish_test