1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Ensure an error is returned if the user specifies an unsupported frame type.

FossilOrigin-Name: 0f3f8fcde1a535bcf93e23a68d2411c21785d8c0cac1f9481a06e7225755cdbc
This commit is contained in:
dan
2018-07-06 14:15:49 +00:00
parent 287fa17b78
commit 5d764ac9e6
4 changed files with 44 additions and 14 deletions

View File

@@ -837,10 +837,26 @@ Window *sqlite3WindowAlloc(
){
Window *pWin = 0;
if( eType==TK_RANGE && (pStart || pEnd) ){
sqlite3ErrorMsg(pParse, "RANGE %s is only supported with UNBOUNDED",
(pStart ? "PRECEDING" : "FOLLOWING")
);
/* If a frame is declared "RANGE" (not "ROWS"), then it may not use
** either "<expr> PRECEDING" or "<expr> FOLLOWING". Additionally, the
** starting boundary type may not occur earlier in the following list than
** the ending boundary type:
**
** UNBOUNDED PRECEDING
** <expr> PRECEDING
** CURRENT ROW
** <expr> FOLLOWING
** UNBOUNDED FOLLOWING
**
** The parser ensures that "UNBOUNDED PRECEDING" cannot be used as an ending
** boundary, and than "UNBOUNDED FOLLOWING" cannot be used as a starting
** frame boundary.
*/
if( eType==TK_RANGE && (pStart || pEnd)
|| (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
|| (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
){
sqlite3ErrorMsg(pParse, "unsupported window-frame type");
}else{
pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
}