aboutsummaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c53
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);
+ }
+}