/ Check-in [ca564d4b]
Login

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

Overview
Comment:Fix a problem with processing CTEs that use a WINDOW clause.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ca564d4b5b19fe56842a04f31bb61352e6ae9d72a7e7634eb27ebcf5f670545a
User & Date: dan 2019-09-16 05:34:08
Context
2019-09-16
14:42
Documentation updates for the SQLITE_DIRECTONLY flag. check-in: 5beb6dc9 user: drh tags: trunk
12:35
Merge all recent trunk enhancements into the reuse-schema branch. check-in: 27eb2236 user: drh tags: reuse-schema
12:23
Merge recent trunk enhancements into the wal2 branch. check-in: da8bc974 user: drh tags: wal2
12:17
Merge recent trunk enhancements into the begin-concurrent-pnu branch. check-in: 54930b7e user: drh tags: begin-concurrent-pnu
12:08
Merge recent trunk enhancements into the begin-concurrent branch. check-in: 93b9ef3f user: drh tags: begin-concurrent
12:02
Merge the latest changes from trunk into the apple-osx branch. check-in: a95191de user: drh tags: apple-osx
05:34
Fix a problem with processing CTEs that use a WINDOW clause. check-in: ca564d4b user: dan tags: trunk
2019-09-14
16:44
Add the --no-rowids option to the ".recover" command. check-in: 01d71b94 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/window.c.

  2211   2211   */
  2212   2212   Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
  2213   2213     Window *pNew = 0;
  2214   2214     if( ALWAYS(p) ){
  2215   2215       pNew = sqlite3DbMallocZero(db, sizeof(Window));
  2216   2216       if( pNew ){
  2217   2217         pNew->zName = sqlite3DbStrDup(db, p->zName);
         2218  +      pNew->zBase = sqlite3DbStrDup(db, p->zBase);
  2218   2219         pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
  2219   2220         pNew->pFunc = p->pFunc;
  2220   2221         pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
  2221   2222         pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
  2222   2223         pNew->eFrmType = p->eFrmType;
  2223   2224         pNew->eEnd = p->eEnd;
  2224   2225         pNew->eStart = p->eStart;
  2225   2226         pNew->eExclude = p->eExclude;
  2226   2227         pNew->regResult = p->regResult;
  2227   2228         pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
  2228   2229         pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
  2229   2230         pNew->pOwner = pOwner;
         2231  +      pNew->bImplicitFrame = p->bImplicitFrame;
  2230   2232       }
  2231   2233     }
  2232   2234     return pNew;
  2233   2235   }
  2234   2236   
  2235   2237   /*
  2236   2238   ** Return a copy of the linked list of Window objects passed as the

Changes to test/windowB.test.

   197    197     } {
   198    198       {{}}
   199    199       {{"a":{"a":1,"e":9}}}
   200    200       {{"a":{"a":1,"e":9}}}
   201    201       {{"c":{"c":3,"e":9}}}
   202    202     }
   203    203   }
          204  +
          205  +#-------------------------------------------------------------------------
          206  +reset_db
          207  +do_execsql_test 4.0 {
          208  +  CREATE TABLE x(a);
          209  +  INSERT INTO x VALUES(1);
          210  +  INSERT INTO x VALUES(2);
          211  +}
          212  +
          213  +do_execsql_test 4.1 {
          214  +  WITH y AS (
          215  +      SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION BY a)
          216  +  )
          217  +  SELECT * FROM y;
          218  +} {
          219  +  1 1
          220  +}
          221  +
          222  +do_catchsql_test 4.2 {
          223  +  WITH y AS (
          224  +    SELECT Row_Number() OVER (win) FROM x WINDOW win AS (PARTITION
          225  +  BY fake_column))
          226  +  SELECT * FROM y;
          227  +} {1 {no such column: fake_column}}
          228  +
          229  +do_catchsql_test 4.3 {
          230  +  SELECT 1 WINDOW win AS (PARTITION BY fake_column);
          231  +} {0 1}
   204    232   
   205    233   finish_test