summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2015-06-11 10:25:57 -0700
committerIgor Babaev <igor@askmonty.org>2015-06-11 10:25:57 -0700
commitad0ba8b7ca28005d9d32e2a614a0162254974e74 (patch)
tree58b411638e72734f288115375f0c68446f29090f
parent6a73446f5bbd0221f72b65da4fc173d21ebffbc2 (diff)
downloadmariadb-git-bb-10.1-mdev6115.tar.gz
A stub performing name resolution of window functions in simplest queries.bb-10.1-mdev6115
-rw-r--r--libmysqld/CMakeLists.txt1
-rw-r--r--sql/CMakeLists.txt3
-rw-r--r--sql/item_windowfunc.cc13
-rw-r--r--sql/item_windowfunc.h4
-rw-r--r--sql/sql_select.cc5
-rw-r--r--sql/sql_window.cc22
-rw-r--r--sql/sql_window.h7
7 files changed, 53 insertions, 2 deletions
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 7168c67e57e..b07ba1dd2f1 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -106,6 +106,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/table_cache.cc
../sql/item_inetfunc.cc
../sql/wsrep_dummy.cc ../sql/encryption_keys.cc
+ ../sql/item_windowfunc.cc ../sql/sql_window.cc
${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE}
)
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 9a2ab3c72c8..79436c8f66b 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -101,7 +101,7 @@ SET (SQL_SOURCE
sql_profile.cc event_parse_data.cc sql_alter.cc
sql_signal.cc rpl_handler.cc mdl.cc sql_admin.cc
transaction.cc sys_vars.cc sql_truncate.cc datadict.cc
- sql_reload.cc sql_cmd.h item_inetfunc.cc
+ sql_reload.cc sql_cmd.h item_inetfunc.cc
# added in MariaDB:
sql_explain.h sql_explain.cc
@@ -115,6 +115,7 @@ SET (SQL_SOURCE
my_apc.cc my_apc.h
my_json_writer.cc my_json_writer.h
rpl_gtid.cc rpl_parallel.cc
+ item_windowfunc.cc sql_window.cc
${WSREP_SOURCES}
table_cache.cc encryption_keys.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
new file mode 100644
index 00000000000..273a0831116
--- /dev/null
+++ b/sql/item_windowfunc.cc
@@ -0,0 +1,13 @@
+#include "item_windowfunc.h"
+
+bool
+Item_window_func::fix_fields(THD *thd, Item **ref)
+{
+ DBUG_ASSERT(fixed == 0);
+
+ if (window_func->fix_fields(thd, ref))
+ return TRUE;
+
+ fixed= 1;
+ return FALSE;
+}
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 47cff870aa5..b2de0e9ca00 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -2,7 +2,7 @@
#define ITEM_WINDOWFUNC_INCLUDED
#include "my_global.h"
-#include "item_sum.h"
+#include "item.h"
class Window_spec;
@@ -161,6 +161,8 @@ public:
void fix_length_and_dec() { }
const char* func_name() const { return "WF"; }
+
+ bool fix_fields(THD *thd, Item **ref);
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 15290b218ac..c84aeec0f90 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -53,6 +53,7 @@
#include "log_slow.h"
#include "sql_derived.h"
#include "sql_statistics.h"
+#include "sql_window.h"
#include "debug_sync.h" // DEBUG_SYNC
#include <m_ctype.h>
@@ -616,6 +617,7 @@ inline int setup_without_group(THD *thd, Item **ref_pointer_array,
COND **conds,
ORDER *order,
ORDER *group,
+ List<Window_spec> &win_specs,
bool *hidden_group_fields,
uint *reserved)
{
@@ -649,6 +651,8 @@ inline int setup_without_group(THD *thd, Item **ref_pointer_array,
res= res || setup_group(thd, ref_pointer_array, tables, fields, all_fields,
group, hidden_group_fields);
thd->lex->allow_sum_func= save_allow_sum_func;
+ res= res || setup_windows(thd, ref_pointer_array, tables, fields, all_fields,
+ win_specs);
DBUG_RETURN(res);
}
@@ -787,6 +791,7 @@ JOIN::prepare(Item ***rref_pointer_array,
setup_without_group(thd, (*rref_pointer_array), tables_list,
select_lex->leaf_tables, fields_list,
all_fields, &conds, order, group_list,
+ select_lex->window_specs,
&hidden_group_fields, &select_lex->select_n_reserved))
DBUG_RETURN(-1); /* purecov: inspected */
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
new file mode 100644
index 00000000000..46d69d3158a
--- /dev/null
+++ b/sql/sql_window.cc
@@ -0,0 +1,22 @@
+#include "sql_select.h"
+#include "sql_window.h"
+
+int
+setup_windows(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
+ List<Item> &fields, List<Item> &all_fields,
+ List<Window_spec> win_specs)
+{
+ int res= 0;
+ Window_spec *win_spec;
+ DBUG_ENTER("setup_windows");
+ List_iterator<Window_spec> it(win_specs);
+ while ((win_spec= it++))
+ {
+ bool hidden_group_fields;
+ res= setup_group(thd, ref_pointer_array, tables, fields, all_fields,
+ win_spec->partition_list.first, &hidden_group_fields);
+ res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields,
+ win_spec->order_list.first);
+ }
+ DBUG_RETURN(res);
+}
diff --git a/sql/sql_window.h b/sql/sql_window.h
index 3e91dad7b09..b300c13136f 100644
--- a/sql/sql_window.h
+++ b/sql/sql_window.h
@@ -2,6 +2,9 @@
#ifndef SQL_WINDOW_INCLUDED
#define SQL_WINDOW_INCLUDED
+#include "my_global.h"
+#include "item.h"
+
class Window_frame_bound : public Sql_alloc
{
@@ -92,4 +95,8 @@ class Window_def : public Window_spec
};
+int setup_windows(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
+ List<Item> &fields, List<Item> &all_fields,
+ List<Window_spec> win_specs);
+
#endif /* SQL_WINDOW_INCLUDED */