mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fix problems with using window functions in CREATE VIEW statements.
FossilOrigin-Name: 943bccd2a6bd4cf3e0534c1fa46885bfa2ba7b780ddcdff9f1ea4cbb3f04e786
This commit is contained in:
23
src/window.c
23
src/window.c
@@ -503,7 +503,7 @@ void sqlite3WindowUpdate(
|
||||
Window *pWin, /* Window frame to update */
|
||||
FuncDef *pFunc /* Window function definition */
|
||||
){
|
||||
if( pWin->zName ){
|
||||
if( pWin->zName && pWin->eType==0 ){
|
||||
Window *p;
|
||||
for(p=pList; p; p=p->pNextWin){
|
||||
if( sqlite3StrICmp(p->zName, pWin->zName)==0 ) break;
|
||||
@@ -518,6 +518,7 @@ void sqlite3WindowUpdate(
|
||||
pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
|
||||
pWin->eStart = p->eStart;
|
||||
pWin->eEnd = p->eEnd;
|
||||
pWin->eType = p->eType;
|
||||
}
|
||||
if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
|
||||
sqlite3 *db = pParse->db;
|
||||
@@ -800,6 +801,7 @@ Window *sqlite3WindowAlloc(
|
||||
Window *pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
|
||||
|
||||
if( pWin ){
|
||||
assert( eType );
|
||||
pWin->eType = eType;
|
||||
pWin->eStart = eStart;
|
||||
pWin->eEnd = eEnd;
|
||||
@@ -1918,6 +1920,7 @@ Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
|
||||
if( p ){
|
||||
pNew = sqlite3DbMallocZero(db, sizeof(Window));
|
||||
if( pNew ){
|
||||
pNew->zName = sqlite3DbStrDup(db, p->zName);
|
||||
pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
|
||||
pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
|
||||
pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
|
||||
@@ -1932,6 +1935,24 @@ Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a copy of the linked list of Window objects passed as the
|
||||
** second argument.
|
||||
*/
|
||||
Window *sqlite3WindowListDup(sqlite3 *db, Window *p){
|
||||
Window *pWin;
|
||||
Window *pRet = 0;
|
||||
Window **pp = &pRet;
|
||||
|
||||
for(pWin=p; pWin; pWin=pWin->pNextWin){
|
||||
*pp = sqlite3WindowDup(db, 0, pWin);
|
||||
if( *pp==0 ) break;
|
||||
pp = &((*pp)->pNextWin);
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/*
|
||||
** sqlite3WhereBegin() has already been called for the SELECT statement
|
||||
** passed as the second argument when this function is invoked. It generates
|
||||
|
Reference in New Issue
Block a user