diff options
author | dan <dan@noemail.net> | 2018-05-16 20:58:07 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2018-05-16 20:58:07 +0000 |
commit | 86fb6e173885b9ac170b14ce9a9d0ccf7cd34e50 (patch) | |
tree | ca728c5c40cf8c1487880b4446d95d75f3cdbe6e /src/window.c | |
parent | f80bba9d8d6a1bff6728db40d8d65af06d0723f9 (diff) | |
download | sqlite-86fb6e173885b9ac170b14ce9a9d0ccf7cd34e50.tar.gz sqlite-86fb6e173885b9ac170b14ce9a9d0ccf7cd34e50.zip |
Start of experimental implementation of SQL window functions. Does not yet
work.
FossilOrigin-Name: 3781e520854808fe02ad3fe77dd11fc917448c58ff1fd79123289dd91937decd
Diffstat (limited to 'src/window.c')
-rw-r--r-- | src/window.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/window.c b/src/window.c new file mode 100644 index 000000000..57d467424 --- /dev/null +++ b/src/window.c @@ -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); + } +} |