/ Check-in [75aec4fc]
Login

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

Overview
Comment:Fix a segfault that could occur following an OOM while processing a SELECT statement for which one or more of the expressions in the window frame declaration are themselves sub-selects that use window functions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 75aec4fc886c04fe098828cc03bc72c197cbf40f0a1890fe5bbb98d4fd5c3c7e
User & Date: dan 2019-08-20 14:43:01
Context
2019-08-20
19:11
Fix a problem with fts5 "ORDER BY rank" queries when the fts5 table name requires quoting. check-in: 00e9a8f2 user: dan tags: trunk
17:14
Bring the hard-heap-limit branch up-to-date with trunk. Leaf check-in: 9b14eb77 user: drh tags: hard-heap-limit
14:43
Fix a segfault that could occur following an OOM while processing a SELECT statement for which one or more of the expressions in the window frame declaration are themselves sub-selects that use window functions. check-in: 75aec4fc user: dan tags: trunk
13:49
Add the new sqlite3_drop_modules() interface to the loadable extension mechanism. check-in: 658bd516 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/expr.c.

  1507   1507       pNew->addrOpenEphm[0] = -1;
  1508   1508       pNew->addrOpenEphm[1] = -1;
  1509   1509       pNew->nSelectRow = p->nSelectRow;
  1510   1510       pNew->pWith = withDup(db, p->pWith);
  1511   1511   #ifndef SQLITE_OMIT_WINDOWFUNC
  1512   1512       pNew->pWin = 0;
  1513   1513       pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
  1514         -    if( p->pWin ) gatherSelectWindows(pNew);
         1514  +    if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
  1515   1515   #endif
  1516   1516       pNew->selId = p->selId;
  1517   1517       *pp = pNew;
  1518   1518       pp = &pNew->pPrior;
  1519   1519       pNext = pNew;
  1520   1520     }
  1521   1521   

Changes to test/windowfault.test.

   219    219     }
   220    220   } -test {
   221    221     faultsim_test_result [list 0 $::L]
   222    222   }
   223    223   
   224    224   catch {db close}
   225    225   tvfs delete
          226  +
          227  +reset_db
          228  +do_execsql_test 10.0 {
          229  +  CREATE TABLE t1(a, b, c, d);
          230  +  CREATE TABLE t2(a, b, c, d);
          231  +}
          232  +
          233  +do_faultsim_test 1 -faults oom* -prep {
          234  +} -body {
          235  +  execsql {
          236  +    SELECT row_number() OVER win
          237  +    FROM t1
          238  +    WINDOW win AS (
          239  +      ORDER BY (
          240  +        SELECT percent_rank() OVER win2 FROM t2
          241  +        WINDOW win2 AS (ORDER BY a)
          242  +      )
          243  +    )
          244  +  }
          245  +} -test {
          246  +  faultsim_test_result {0 {}}
          247  +}
   226    248   
   227    249   finish_test