summaryrefslogtreecommitdiff
path: root/sql/sql_window.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2016-04-10 16:24:04 +0200
committerSergei Petrunia <psergey@askmonty.org>2016-04-10 16:24:04 +0200
commitda7c5e3b857b671a1ac4534ee814d11218098d40 (patch)
tree54605d0975c37efa5bd2c5b240842364d6653700 /sql/sql_window.cc
parent2905b2feb605d9688394eff21b6bbade1921732e (diff)
downloadmariadb-git-da7c5e3b857b671a1ac4534ee814d11218098d40.tar.gz
MDEV-9895: Assertion `n_rows > 0' failed in Frame_cursor* get_frame_cursor
n=0 in "ROWS 0 PRECEDING" is valid, add handling for it: - Adjust the assert - Bottom bound of 'ROW 0 PRECEDING' is actually looking at the current row, that is, it needs to process partition's first row directly in Frame_n_rows_preceding::next_partition(). - Added testcases
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r--sql/sql_window.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 3753e2499c3..d4de1ac57c6 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -1279,6 +1279,14 @@ public:
- top bound should remove row (#n-3) from the window function.
*/
n_rows_to_skip= n_rows + (is_top_bound? 1:0) - 1;
+
+ /* Bottom bound "ROWS 0 PRECEDING" is a special case: */
+ if (n_rows_to_skip == -1)
+ {
+ cursor.get_next();
+ item->add();
+ n_rows_to_skip= 0;
+ }
}
void next_row(Item_sum* item)
@@ -1496,7 +1504,7 @@ Frame_cursor *get_frame_cursor(Window_frame *frame, bool is_top_bound)
longlong n_rows= bound->offset->val_int();
/* These should be handled in the parser */
DBUG_ASSERT(!bound->offset->null_value);
- DBUG_ASSERT(n_rows > 0);
+ DBUG_ASSERT(n_rows >= 0);
if (is_preceding)
return new Frame_n_rows_preceding(is_top_bound, n_rows);
else