Lines Matching refs:window

5658 ** needed by [aggregate window functions].
5735 ** or aggregate window function. More details regarding the implementation
5736 ** of aggregate window functions are
5737 ** [user-defined window functions|available here].
17788 #define SQLITE_WindowFunc 0x00000002 /* Use xInverse for window functions */
17929 #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
18964 #define EP_Win 0x008000 /* Contains window functions */
19047 ** an OVER() clause (a window function).
19316 Select *pWinSelect; /* SELECT statement for any window functions */
19344 #define NC_HasWin 0x008000 /* One or more window functions seen */
19422 Window *pWin; /* List of window functions */
19423 Window *pWinDefn; /* List of named window definitions */
20325 ** This object is used in various ways, most (but not all) related to window
20329 ** the Expr.y.pWin field for each window function in an expression tree.
20333 ** (2) All window functions in a single SELECT form a linked-list
20335 ** fields point back to the expression that is the window function.
20348 char *zName; /* Name of window (may be NULL) */
20349 char *zBase; /* Name of base window for chaining (may be NULL) */
20360 Window *pNextWin; /* Next window function belonging to this SELECT */
20369 Expr *pOwner; /* Expression object this window is attached to */
20375 u8 bExprArgs; /* Defer evaluation of window function arguments
32555 sqlite3TreeViewLine(pView, "window-functions");
32680 sqlite3TreeViewLine(pView, "window: %s", pWin->zBase);
100284 ** or window function. Execute the finalizer function
106021 ** symbols (e.g. a table that does not exist) in a window definition. */
106166 ** See also the sqlite3WindowExtraAggFuncDepth() routine in window.c
106781 sqlite3ErrorMsg(pParse, "misuse of aliased window function %s",zAs);
107286 "%#T() may not be used as a window function", pExpr
107296 zType = "window";
107338 ** Or arguments of other window functions. But aggregate functions
107339 ** may be arguments for window functions. */
144376 sqlite3ErrorMsg(pParse, "cannot use window functions in recursive queries");
145977 ** (17e) the subquery may not contain window functions, and
146027 ** (25) If either the subquery or the parent query contains a window
146755 ** pSubq, which contains at least one window function. Return 1
146761 ** BY clause of all window function used by the sub-query. It is safe
146763 ** this may change the results of the window functions.
146767 ** * the sub-query uses only one distinct window frame, and
146768 ** * that the window frame has a PARTITION BY clause.
146827 ** of the inner query could change the window over which window
146831 ** (6a) The inner query uses multiple incompatible window partitions.
146833 ** (6b) The inner query is a compound and uses window-functions.
146837 ** all window-functions used by the sub-query. It is safe to
146839 ** window over which any window-function is calculated.
147050 /* This optimization does not work for subqueries that use window
147254 ** SELECT is rewritten for window-functions processing and then passed
148840 if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */
149109 TREETRACE(0x40,pParse,p, ("after window rewrite:\n"));
149222 ** (2) The subquery was added to help with window-function
149636 Window *pWin = p->pWin; /* Main window object (or NULL) */
160335 ** not use window functions.
167802 /************** Begin file window.c ******************************************/
167822 ** Any SELECT statement that contains one or more window functions in
167823 ** either the select list or ORDER BY clause (the only two places window
167825 ** in order to support window function processing. For example, with the
167841 ** SELECT statement. This allows the implementation of the window function
167855 ** If there is more than one window function in the SELECT that uses
167856 ** the same window declaration (the OVER bit), then a single scan may
167857 ** be used to process more than one window function. For example:
167878 ** their respective window declarations.
167892 ** * The results of all window-functions for the row are stored
167898 ** In some cases, depending on the window frame and the specific window
167906 ** This implementation features the following built-in window functions:
167920 ** These are the same built-in window functions supported by Postgres.
167921 ** Although the behaviour of aggregate window functions (functions that
167922 ** can be used as either aggregates or window functions) allows them to
167923 ** be implemented using an API, built-in window functions are much more
167924 ** esoteric. Additionally, some window functions (e.g. nth_value())
167926 ** As such, some built-in window functions use the same API as aggregate
167927 ** window functions and some are implemented directly using VDBE
167929 ** window frame is sometimes modified before the SELECT statement is
167930 ** rewritten. For example, regardless of the specified window frame, the
167937 ** As well as some of the built-in window functions, aggregate window
167939 ** the start of the window frame is declared as anything other than
167944 ** Implementation of built-in window function row_number(). Assumes that the
167945 ** window frame has been coerced to:
167975 ** Implementation of built-in window function dense_rank(). Assumes that
167976 ** the window frame has been set to:
168004 ** Implementation of built-in window function nth_value(). This
168094 ** Implementation of built-in window function rank(). Assumes that
168095 ** the window frame has been set to:
168125 ** Implementation of built-in window function percent_rank(). Assumes that
168126 ** the window frame has been set to:
168170 ** Implementation of built-in window function cume_dist(). Assumes that
168171 ** the window frame has been set to:
168210 ** Context object for ntile() window function.
168219 ** Implementation of ntile(). This assumes that the window frame has
168280 ** Context object for last_value() window function.
168343 ** Static names for the built-in window function names. These static
168345 ** can be associated with a particular window function by direct
168364 ** for built-in window functions that never call those interfaces.
168383 /* Window functions that use all window interfaces: xStep, xFinal,
168399 /* Window functions that use all window interfaces: xStep, the
168410 ** Register those built-in window functions that are not also aggregates.
168439 sqlite3ErrorMsg(pParse, "no such window: %s", zName);
168446 ** for a window function within a SELECT statement. Argument pList is a
168452 ** * If the OVER clause referred to a named window (as in "max(x) OVER win"),
168457 ** * If the function is a built-in window function that requires the
168458 ** window to be coerced (see "BUILT-IN WINDOW FUNCTIONS" at the top
168493 "FILTER clause may only be used with aggregate window functions"
168559 ** not process aggregates or window functions at all, as they belong
168652 ** * window function with a Window object that is not a member of the
168755 ** any SQL window functions, this function is a no-op. Otherwise, it
168756 ** rewrites the SELECT statement so that window function xStep functions
168777 Window *pMWin = p->pWin; /* Main window object */
168804 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
168834 /* Append the arguments passed to each window function to the
168836 ** window function - one for the accumulator, another for interim
168860 /* If there is no ORDER BY or PARTITION BY clause, and the window
168876 ("New window-function subquery in FROM clause of (%u/%p)\n",
168984 Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */
168986 Expr *pEnd, /* End window size if TK_FOLLOWING or PRECEDING */
169048 ** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window
169074 ** is the base window. Earlier windows from the same WINDOW clause are
169095 "cannot override %s of window: %s", zErr, pWin->zBase
169111 ** Attach window object pWin to expression p.
169123 "DISTINCT is not supported for window functions"
169132 ** Possibly link window pWin into the list at pSel->pWin (window functions
169133 ** to be processed as part of SELECT statement pSel). The window is linked
169135 ** SELECT, or (b) the windows already linked use a compatible window frame.
169155 ** Return 0 if the two window objects are identical, 1 if they are
169157 ** or not. Identical window objects can be processed in a single scan.
169324 ** Return the number of arguments passed to the window-function associated
169352 ** Each window function requires an accumulator register (just as an
169354 ** in an array of accumulator registers - one for each window function
169358 ** The window functions implementation sometimes caches the input rows
169368 ** An input row can be discarded after the window functions xInverse()
169372 ** An input row can be discarded after the window functions xStep()
169376 ** Consider a window-frame similar to the following:
169385 ** once its window function values have been calculated. Another (end)
169386 ** points to the next row to call the xStep() method of each window function
169388 ** points to the next row to call the xInverse() method of each window
169396 ** Depending on the window-frame in question, all three cursors may not
169416 ** Generate VM code to read the window frames peer values from cursor csr into
169439 ** xInverse (if bInverse is non-zero) for each window function in the
169440 ** linked list starting at pMWin. Or, for built-in window functions
169458 Window *pMWin, /* Linked list of window functions */
169474 /* All OVER clauses in the same window function aggregate step must
169569 ** (bFin==1) for each window function in the linked list starting at
169570 ** pMWin. Or, for built-in window-functions that do not use the standard
169607 ** Generate code to calculate the current values of all window functions in the
169608 ** p->pMWin list by doing a full scan of the current window frame. Store the
169707 ** return the current row of Window.iEphCsr. If all window functions are
169708 ** aggregate window functions that use the standard API, a single
169710 ** for per-row processing is only generated for the following built-in window
169790 ** Generate code to set the accumulator register for each window function
169792 ** any equivalent initialization required by any built-in window functions
169879 ** the ORDER BY term in the window, and that argument op is OP_Ge, it generates
169887 ** If the sort-order for the ORDER BY term in the window is DESC, then the
169909 ExprList *pOrderBy = p->pMWin->pOrderBy; /* ORDER BY clause for window */
170250 ** code to populate the Window.regResult register for each window function
170254 ** This function handles several different types of window frames, which
170256 ** used to implement window frames of the form:
170260 ** Other window frame types use variants of the following:
170302 ** AGGSTEP: invoke the aggregate xStep() function for each window function
170310 ** AGGINVERSE: invoke the aggregate xInverse() function for each window
170314 ** There are two other ROWS window frames that are handled significantly
170474 ** RANGE window frames are a little different again. As for GROUPS, the
170637 ** be deleted as soon as they are no longer part of the window frame
170675 /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING"
170707 ** at regNew. If the window has a PARTITION clause, this block generates
170906 /************** End of window.c **********************************************/
172712 /* 308 */ "window",
173042 /* 312 */ "windowdefn ::= nm AS LP window RP",
173043 /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
173044 /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
173045 /* 315 */ "window ::= ORDER BY sortlist frame_opt",
173046 /* 316 */ "window ::= nm ORDER BY sortlist frame_opt",
173047 /* 317 */ "window ::= nm frame_opt",
173067 /* 337 */ "over_clause ::= OVER LP window RP",
173134 /* 404 */ "window ::= frame_opt",
173328 case 308: /* window */
173953 307, /* (312) windowdefn ::= nm AS LP window RP */
173954 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
173955 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
173956 308, /* (315) window ::= ORDER BY sortlist frame_opt */
173957 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */
173958 308, /* (317) window ::= nm frame_opt */
173978 312, /* (337) over_clause ::= OVER LP window RP */
174045 308, /* (404) window ::= frame_opt */
174363 -5, /* (312) windowdefn ::= nm AS LP window RP */
174364 -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
174365 -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
174366 -4, /* (315) window ::= ORDER BY sortlist frame_opt */
174367 -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */
174368 -2, /* (317) window ::= nm frame_opt */
174388 -4, /* (337) over_clause ::= OVER LP window RP */
174455 -1, /* (404) window ::= frame_opt */
175830 case 312: /* windowdefn ::= nm AS LP window RP */
175839 case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
175844 case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
175850 case 315: /* window ::= ORDER BY sortlist frame_opt */
175855 case 316: /* window ::= nm ORDER BY sortlist frame_opt */
175861 case 317: /* window ::= nm frame_opt */
175944 case 337: /* over_clause ::= OVER LP window RP */
176026 /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404);
177084 ** impossible to call a window-function without a FILTER clause.