SQLite

Check-in [c621fc66]
Login

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

Overview
Comment:Fix a stack overflow that could occur when renaming a table that has a trigger containing a window function invocation that itself contains a specific syntax error.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c621fc668c6538f9f5bdac204f012c64998679a61aa8e224d212503820224c09
User & Date: dan 2019-04-29 11:27:58
Context
2019-04-29
11:41
Fix a buffer overwrite in shell.c.in (part of the new .recover code). (check-in: 92facbc7 user: dan tags: trunk)
11:27
Fix a stack overflow that could occur when renaming a table that has a trigger containing a window function invocation that itself contains a specific syntax error. (check-in: c621fc66 user: dan tags: trunk)
2019-04-27
20:30
Add the ".recover" command to the shell tool. For recovering as much data as possible from corrupt databases. (check-in: 50fe4845 user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

862
863
864
865
866
867
868

869

870
871
872
873
874
875
876
        }
      }
      sqlite3WalkExprList(pWalker, pList);
      if( is_agg ){
#ifndef SQLITE_OMIT_WINDOWFUNC
        if( pExpr->y.pWin ){
          Select *pSel = pNC->pWinSelect;

          sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);

          sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
          sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
          sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
          if( 0==pSel->pWin 
           || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin) 
          ){
            pExpr->y.pWin->pNextWin = pSel->pWin;







>
|
>







862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
        }
      }
      sqlite3WalkExprList(pWalker, pList);
      if( is_agg ){
#ifndef SQLITE_OMIT_WINDOWFUNC
        if( pExpr->y.pWin ){
          Select *pSel = pNC->pWinSelect;
          if( IN_RENAME_OBJECT==0 ){
            sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
          }
          sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
          sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
          sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
          if( 0==pSel->pWin 
           || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin) 
          ){
            pExpr->y.pWin->pNextWin = pSel->pWin;

Changes to test/altertab3.test.

137
138
139
140
141
142
143

































144
145
146
147
    FOREIGN KEY (Col0) REFERENCES Table0
  );
}

do_execsql_test 6.1 {
  ALTER TABLE Table0 RENAME Col0 TO Col0;
}


































finish_test









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




137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    FOREIGN KEY (Col0) REFERENCES Table0
  );
}

do_execsql_test 6.1 {
  ALTER TABLE Table0 RENAME Col0 TO Col0;
}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 7.1.0 {
  CREATE TABLE t1(a,b,c);
  CREATE TRIGGER AFTER INSERT ON t1 BEGIN
    SELECT a, rank() OVER w1 FROM t1
    WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1);
  END;
}

do_execsql_test 7.1.2 {
  ALTER TABLE t1 RENAME TO t1x;
  SELECT sql FROM sqlite_master;
} {
  {CREATE TABLE "t1x"(a,b,c)}
  {CREATE TRIGGER AFTER INSERT ON "t1x" BEGIN
    SELECT a, rank() OVER w1 FROM "t1x"
    WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1);
  END}
}

do_execsql_test 7.2.1 {
  DROP TRIGGER after;
  CREATE TRIGGER AFTER INSERT ON t1x BEGIN
    SELECT a, rank() OVER w1 FROM t1x
    WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1 ORDER BY d);
  END;
}

do_catchsql_test 7.2.2 {
  ALTER TABLE t1x RENAME TO t1;
} {1 {error in trigger AFTER: no such column: d}}

finish_test