/ Check-in [d7c816ae]
Login

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

Overview
Comment:Slightly smaller and faster alternative to [507d892c3a40a0bacbd47] that fixes a problem with views that use window function as part of complex expressions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d7c816ae15f05f21b9b213161e1044aaefc56f17e7bc4b7b551a9e04efc05855
User & Date: drh 2018-09-24 15:39:30
Context
2018-09-25
13:51
Fix a problem in releasetest.tcl causing configuration "Fast-One" to fail. check-in: 42e04fef user: dan tags: trunk
2018-09-24
15:39
Slightly smaller and faster alternative to [507d892c3a40a0bacbd47] that fixes a problem with views that use window function as part of complex expressions. check-in: d7c816ae user: drh tags: trunk
14:51
Fix a problem with views that use window functions as part of complex expressions. check-in: 507d892c user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  1266   1266           pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags);
  1267   1267         }else{
  1268   1268           pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);
  1269   1269         }
  1270   1270       }
  1271   1271   
  1272   1272       /* Fill in pNew->pLeft and pNew->pRight. */
  1273         -    zAlloc += dupedExprNodeSize(p, dupFlags);
  1274         -    if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){
         1273  +    if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){
         1274  +      zAlloc += dupedExprNodeSize(p, dupFlags);
  1275   1275         if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){
  1276   1276           pNew->pLeft = p->pLeft ?
  1277   1277                         exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;
  1278   1278           pNew->pRight = p->pRight ?
  1279   1279                          exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;
  1280   1280         }
  1281         -    }else{
  1282   1281   #ifndef SQLITE_OMIT_WINDOWFUNC
  1283   1282         if( ExprHasProperty(p, EP_WinFunc) ){
  1284   1283           pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin);
  1285   1284           assert( ExprHasProperty(pNew, EP_WinFunc) );
  1286   1285         }
  1287   1286   #endif /* SQLITE_OMIT_WINDOWFUNC */
         1287  +      if( pzBuffer ){
         1288  +        *pzBuffer = zAlloc;
         1289  +      }
         1290  +    }else{
  1288   1291         if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
  1289   1292           if( pNew->op==TK_SELECT_COLUMN ){
  1290   1293             pNew->pLeft = p->pLeft;
  1291   1294             assert( p->iColumn==0 || p->pRight==0 );
  1292   1295             assert( p->pRight==0  || p->pRight==p->pLeft );
  1293   1296           }else{
  1294   1297             pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
  1295   1298           }
  1296   1299           pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);
  1297   1300         }
  1298   1301       }
  1299         -    if( pzBuffer ){
  1300         -      *pzBuffer = zAlloc;
  1301         -    }
  1302   1302     }
  1303   1303     return pNew;
  1304   1304   }
  1305   1305   
  1306   1306   /*
  1307   1307   ** Create and return a deep copy of the object passed as the second 
  1308   1308   ** argument. If an OOM condition is encountered, NULL is returned