summaryrefslogtreecommitdiff
path: root/sql/sql_window.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2016-09-29 01:15:00 -0700
committerIgor Babaev <igor@askmonty.org>2016-09-30 17:40:40 -0700
commit903f34c7a99d15ca1b861a7dd4848ebed9891c44 (patch)
tree80e25801f2ae4bc53bf1705c6360d8062a14c702 /sql/sql_window.cc
parent6aeaebd8cfa3ce3cf7037a282a77ca4c6cdb7e16 (diff)
downloadmariadb-git-903f34c7a99d15ca1b861a7dd4848ebed9891c44.tar.gz
Fixed bug mdev-10868.
There was no implementation of the virtual method print() for the Item_window_func class. As a result for a view containing window function an invalid view definition could be written in the frm file. When a query that refers to this view was executed a syntax error was reported.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r--sql/sql_window.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 8fed2418b82..28be70c2890 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -61,6 +61,25 @@ Window_spec::check_window_names(List_iterator_fast<Window_spec> &it)
return false;
}
+void
+Window_spec::print(String *str, enum_query_type query_type)
+{
+ str->append('(');
+ if (partition_list->first)
+ {
+ str->append(STRING_WITH_LEN(" partition by "));
+ st_select_lex::print_order(str, partition_list->first, query_type);
+ }
+ if (order_list->first)
+ {
+ str->append(STRING_WITH_LEN(" order by "));
+ st_select_lex::print_order(str, order_list->first, query_type);
+ }
+ if (window_frame)
+ window_frame->print(str, query_type);
+ str->append(')');
+}
+
bool
Window_frame::check_frame_bounds()
{
@@ -81,6 +100,65 @@ Window_frame::check_frame_bounds()
}
+void
+Window_frame::print(String *str, enum_query_type query_type)
+{
+ switch (units) {
+ case UNITS_ROWS:
+ str->append(STRING_WITH_LEN(" rows "));
+ break;
+ case UNITS_RANGE: str->append(STRING_WITH_LEN(" range "));
+ }
+
+ str->append(STRING_WITH_LEN("between "));
+ top_bound->print(str, query_type);
+ str->append(STRING_WITH_LEN(" and "));
+ bottom_bound->print(str, query_type);
+
+ if (exclusion != EXCL_NONE)
+ {
+ str->append(STRING_WITH_LEN(" exclude "));
+ switch (exclusion) {
+ case EXCL_CURRENT_ROW:
+ str->append(STRING_WITH_LEN(" current row "));
+ break;
+ case EXCL_GROUP:
+ str->append(STRING_WITH_LEN(" group "));
+ break;
+ case EXCL_TIES:
+ str->append(STRING_WITH_LEN(" ties "));
+ break;
+ default:
+ ;
+ }
+ }
+}
+
+
+void
+Window_frame_bound::print(String *str, enum_query_type query_type)
+{
+ if (precedence_type == CURRENT)
+ {
+ str->append(STRING_WITH_LEN(" current row "));
+ return;
+ }
+ if (is_unbounded())
+ str->append(STRING_WITH_LEN(" unbounded "));
+ else
+ offset->print(str ,query_type);
+ switch (precedence_type) {
+ case PRECEDING:
+ str->append(STRING_WITH_LEN(" preceding "));
+ break;
+ case FOLLOWING:
+ str->append(STRING_WITH_LEN(" following "));
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+}
+
/*
Setup window functions in a select
*/