mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Start of experimental implementation of SQL window functions. Does not yet
work. FossilOrigin-Name: 3781e520854808fe02ad3fe77dd11fc917448c58ff1fd79123289dd91937decd
This commit is contained in:
53
src/window.c
Normal file
53
src/window.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
void sqlite3WindowDelete(sqlite3 *db, Window *p){
|
||||
if( p ){
|
||||
sqlite3ExprDelete(db, p->pFilter);
|
||||
sqlite3ExprListDelete(db, p->pPartition);
|
||||
sqlite3ExprListDelete(db, p->pOrderBy);
|
||||
sqlite3ExprDelete(db, p->pEnd);
|
||||
sqlite3ExprDelete(db, p->pStart);
|
||||
sqlite3DbFree(db, p);
|
||||
}
|
||||
}
|
||||
|
||||
Window *sqlite3WindowAlloc(
|
||||
Parse *pParse,
|
||||
int eType,
|
||||
int eEnd, Expr *pEnd,
|
||||
int eStart, Expr *pStart
|
||||
){
|
||||
Window *pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
|
||||
|
||||
if( pWin ){
|
||||
pWin->eType = eType;
|
||||
pWin->eStart = eStart;
|
||||
pWin->eEnd = eEnd;
|
||||
pWin->pEnd = pEnd;
|
||||
pWin->pStart = pStart;
|
||||
}else{
|
||||
sqlite3ExprDelete(pParse->db, pEnd);
|
||||
sqlite3ExprDelete(pParse->db, pStart);
|
||||
}
|
||||
|
||||
return pWin;
|
||||
}
|
||||
|
||||
void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
|
||||
if( p ){
|
||||
p->pWin = pWin;
|
||||
}else{
|
||||
sqlite3WindowDelete(pParse->db, pWin);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user