diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2016-02-07 02:32:03 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2016-02-07 02:32:03 +0300 |
commit | 32c7f333914c1218d975a2a4204ac506ee3b21eb (patch) | |
tree | 73582ffbdd4646167c6f86597313a245ceb1e4d5 | |
parent | 11112cea18d9ecb71957a0ae348ab2503ef2cdeb (diff) | |
download | mariadb-git-10.2-window_simple.tar.gz |
Fix parsing of Window Frame bounds10.2-window_simple
-rw-r--r-- | sql/sql_window.h | 20 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 37 |
2 files changed, 43 insertions, 14 deletions
diff --git a/sql/sql_window.h b/sql/sql_window.h index 144a9037aa9..551af3ac1ee 100644 --- a/sql/sql_window.h +++ b/sql/sql_window.h @@ -12,27 +12,41 @@ */ +/* + Window frame bound. This is a parsed representation of this syntax: + (UNBOUNDED | unsigned_value) (PRECEDING | FOLLOWING) + CURRENT_ROW +*/ + class Window_frame_bound : public Sql_alloc { - public: - enum Bound_precedence_type { PRECEDING, FOLLOWING }; + /* Either PRECEDING or FOLLOWING */ Bound_precedence_type precedence_type; + /* + NULL - means CURRENT ROW + (Item*)1 - means "UNBOUNDED" (TODO switch to a named constant!) + other - is an unsigned_value (TODO: does the parser really check?) + */ Item *offset; + + Window_frame_bound(enum Bound_precedence_type type_arg, + Item *offset_arg) : + precedence_type(type_arg), offset(offset_arg) + {} }; class Window_frame : public Sql_alloc { - public: enum Frame_units diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3cc76c51439..f6e06a05cca 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11494,28 +11494,43 @@ window_frame_extent: window_frame_start: UNBOUNDED_SYM PRECEDING_SYM { - $$->precedence_type= Window_frame_bound::PRECEDING; - $$->offset= (Item *) 1; + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::PRECEDING, + (Item*)1); + if ($$ == NULL) + MYSQL_YYABORT; } - | CURRENT_SYM ROW_SYM { $$->offset= (Item *) 0; } + | CURRENT_SYM ROW_SYM + { + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::PRECEDING, NULL); + if ($$ == NULL) + MYSQL_YYABORT; + } | literal PRECEDING_SYM { - $$->precedence_type= Window_frame_bound::PRECEDING; - $$->offset= $1; + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::PRECEDING, $1); + if ($$ == NULL) + MYSQL_YYABORT; } ; window_frame_bound: window_frame_start { $$= $1; } - | UNBOUNDED_SYM FOLLOWING_SYM + | UNBOUNDED_SYM FOLLOWING_SYM { - $$->precedence_type= Window_frame_bound::FOLLOWING; - $$->offset= (Item *) 1; - } + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::FOLLOWING, (Item*)1); + if ($$ == NULL) + MYSQL_YYABORT; + } | literal FOLLOWING_SYM { - $$->precedence_type= Window_frame_bound::FOLLOWING; - $$->offset= $1; + $$= new (thd->mem_root) + Window_frame_bound(Window_frame_bound::FOLLOWING, $1); + if ($$ == NULL) + MYSQL_YYABORT; } ; |