/ Check-in [ee076c28]
Login

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

Overview
Comment:Fix a faulty assert() in walker.c that could fail when processing an ALTER TABLE statement on a schema containing invalid table references that are part of a WINDOW definition.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ee076c28d8ee0f5b099cdef83ae6cea6ef5aa209ab528d7c49949dd653ce019c
User & Date: dan 2019-07-19 10:31:29
Context
2019-07-19
11:20
Fix a problem with renaming tables when the schema contains WINDOW definitions with (illegal) non-numeric expressions as part of a PRECEDING or FOLLOWING clause. check-in: 348e7f19 user: dan tags: trunk
10:31
Fix a faulty assert() in walker.c that could fail when processing an ALTER TABLE statement on a schema containing invalid table references that are part of a WINDOW definition. check-in: ee076c28 user: dan tags: trunk
01:11
Fix a new problem in the BETWEEN operator when applied to a window function. The problem was introduced yesterday by check-in [7ef7b23cbb1b9ace]. check-in: 47e23064 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/walker.c.

   116    116     if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
   117    117     if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
   118    118     if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
   119    119   #if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
   120    120     {
   121    121       Parse *pParse = pWalker->pParse;
   122    122       if( pParse && IN_RENAME_OBJECT ){
          123  +      /* The following may return WRC_Abort if there are unresolvable
          124  +      ** symbols (e.g. a table that does not exist) in a window definition. */
   123    125         int rc = walkWindowList(pWalker, p->pWinDefn);
   124         -      assert( rc==WRC_Continue );
   125    126         return rc;
   126    127       }
   127    128     }
   128    129   #endif
   129    130     return WRC_Continue;
   130    131   }
   131    132   

Changes to test/altertab3.test.

   233    233     SELECT sql FROM sqlite_master WHERE name='v1';
   234    234   } {
   235    235     {CREATE VIEW v1 AS SELECT * FROM t1 WHERE (
   236    236       SELECT t1.a FROM t1, t2
   237    237     ) IN () OR t1.a=5}
   238    238   }
   239    239   
          240  +#-------------------------------------------------------------------------
          241  +reset_db
          242  +do_execsql_test 11.1 {
          243  +  CREATE TABLE t1(
          244  +      a,b,c,d,e,f,g,h,j,jj,jjb,k,aa,bb,cc,dd,ee DEFAULT 3.14,
          245  +      ff DEFAULT('hiccup'),Wg NOD NULL DEFAULT(false)
          246  +  );
          247  +
          248  +  CREATE TRIGGER b AFTER INSERT ON t1 WHEN new.a BEGIN
          249  +    SELECT a, sum() w3 FROM t1 
          250  +    WINDOW b AS (ORDER BY NOT EXISTS(SELECT 1 FROM abc));
          251  +  END;
          252  +}
          253  +
          254  +do_catchsql_test 11.2 {
          255  +  ALTER TABLE t1 RENAME TO t1x;
          256  +} {1 {error in trigger b: no such table: abc}}
          257  +
          258  +do_execsql_test 11.3 {
          259  +  DROP TRIGGER b;
          260  +  CREATE TRIGGER b AFTER INSERT ON t1 WHEN new.a BEGIN
          261  +    SELECT a, sum() w3 FROM t1 
          262  +    WINDOW b AS (ORDER BY NOT EXISTS(SELECT 1 FROM t1));
          263  +  END;
          264  +} {}
          265  +
          266  +do_execsql_test 11.4 {
          267  +  ALTER TABLE t1 RENAME TO t1x;
          268  +  SELECT sql FROM sqlite_master WHERE name = 'b';
          269  +} {
          270  +{CREATE TRIGGER b AFTER INSERT ON "t1x" WHEN new.a BEGIN
          271  +    SELECT a, sum() w3 FROM "t1x" 
          272  +    WINDOW b AS (ORDER BY NOT EXISTS(SELECT 1 FROM "t1x"));
          273  +  END}
          274  +}
   240    275   
   241    276   finish_test