SQLite

Check-in [05080344dc]
Login

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

Overview
Comment:Fix a bug in the linked-list handling code added by commit [fd7316cd].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 05080344dceafcfb670fbf01f7d69a1d713a54b6845f968a9cfe941fb53b13af
User & Date: dan 2019-07-22 17:28:43.613
Context
2023-11-29
16:07
Remove Window objects from the corresponding Select.pWin list when they are deleted, as they are, for example, when the ORDER BY clause is optimized out. (check-in: f9c6e6a710 user: drh tags: branch-3.28)
2019-07-22
19:01
Consolidate the removal of Window objects from the Select.pWin list into a single subroutine. (check-in: e46b2afc99 user: drh tags: trunk)
17:28
Fix a bug in the linked-list handling code added by commit [fd7316cd]. (check-in: 05080344dc user: dan tags: trunk)
16:57
New test cases added to test/fuzzdata8.db (check-in: 25fec62ac5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
1326
1327
1328
1329
1330
1331
1332

1333
1334
1335
1336
1337
1338
1339
1340
1341
*/
static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
  if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_WinFunc) ){
    Select *pSelect = pWalker->u.pSelect;
    Window *pWin = pExpr->y.pWin;
    assert( pWin );
    assert( IsWindowFunc(pExpr) );

    if( pSelect->pWin ){
      *pSelect->pWin->ppThis = pSelect->pWin->pNextWin;
      pSelect->pWin->ppThis = &pWin->pNextWin;
    }
    pWin->pNextWin = pSelect->pWin;
    pWin->ppThis = &pSelect->pWin;
    pSelect->pWin = pWin;
  }
  return WRC_Continue;







>

<







1326
1327
1328
1329
1330
1331
1332
1333
1334

1335
1336
1337
1338
1339
1340
1341
*/
static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
  if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_WinFunc) ){
    Select *pSelect = pWalker->u.pSelect;
    Window *pWin = pExpr->y.pWin;
    assert( pWin );
    assert( IsWindowFunc(pExpr) );
    assert( pWin->ppThis==0 );
    if( pSelect->pWin ){

      pSelect->pWin->ppThis = &pWin->pNextWin;
    }
    pWin->pNextWin = pSelect->pWin;
    pWin->ppThis = &pSelect->pWin;
    pSelect->pWin = pWin;
  }
  return WRC_Continue;
Changes to test/window9.test.
117
118
119
120
121
122
123










124
125
126
do_catchsql_test 3.3 {
  SELECT a, sum(a) OVER (ORDER BY a DESC) FROM t2 
  ORDER BY EXISTS(
    SELECT 1 FROM t2 ORDER BY sum(a) OVER (ORDER BY a)
  ) OVER (ORDER BY a);
} {1 {near "OVER": syntax error}}












finish_test








>
>
>
>
>
>
>
>
>
>



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
do_catchsql_test 3.3 {
  SELECT a, sum(a) OVER (ORDER BY a DESC) FROM t2 
  ORDER BY EXISTS(
    SELECT 1 FROM t2 ORDER BY sum(a) OVER (ORDER BY a)
  ) OVER (ORDER BY a);
} {1 {near "OVER": syntax error}}

do_catchsql_test 3.4 {
  SELECT y, y+1, y+2 FROM (
      SELECT c IN (
        SELECT min(a) OVER (),
        (abs(row_number() OVER())+22)/19,
        max(a) OVER () FROM t1
        ) AS y FROM t2
      );
} {1 {sub-select returns 3 columns - expected 1}}


finish_test