Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
39d3cdbf
Commit
39d3cdbf
authored
Mar 24, 2016
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encapsulate the switching between different return values in Item_window_func
parent
722f1b2d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
17 deletions
+29
-17
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+1
-2
sql/item_windowfunc.h
sql/item_windowfunc.h
+26
-13
sql/sql_window.cc
sql/sql_window.cc
+2
-2
No files found.
sql/item_windowfunc.cc
View file @
39d3cdbf
...
...
@@ -112,8 +112,7 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
maybe_null
=
window_func
()
->
maybe_null
;
fixed
=
1
;
force_return_blank
=
true
;
read_value_from_result_field
=
false
;
set_phase_to_initial
();
return
false
;
}
...
...
sql/item_windowfunc.h
View file @
39d3cdbf
...
...
@@ -549,28 +549,41 @@ class Item_window_func : public Item_func_or_sum
Window functions are very special functions, so val_() methods have
special meaning for them:
- Phase#1: we run the join and put its result into temporary table. For
window functions, we write NULL (or some other) values as placeholders.
- Phase#1, "Initial" we run the join and put its result into temporary
table. For window functions, we write the default value (NULL?) as
a placeholder.
- Phase#2:
executor does the scan in {PARTITION, ORDER BY} order of this
window function. It calls appropriate methods to inform the window
function about rows entering/leaving the window.
It calls window_func()->val_int() so that current window function value
- Phase#2:
"Computation": executor does the scan in {PARTITION, ORDER BY}
order of this window function. It calls appropriate methods to inform
the window
function about rows entering/leaving the window.
It calls window_func()->val_int() so that current window function value
can be saved and stored in the temp.table.
- Phase#3:
the temporary table is read and passed to query output.
However, Item_window_func still remains in the select list, so
item_windowfunc->val_int() will be called.
- Phase#3:
"Retrieval" the temporary table is read and passed to query
output. However, Item_window_func still remains in the select list,
so
item_windowfunc->val_int() will be called.
During Phase#3, read_value_from_result_field= true.
*/
public:
// TODO: how to reset this for subquery re-execution??
bool
force_return_blank
;
private:
bool
read_value_from_result_field
;
public:
void
set_phase_to_initial
()
{
force_return_blank
=
true
;
read_value_from_result_field
=
false
;
}
void
set_phase_to_computation
()
{
force_return_blank
=
false
;
read_value_from_result_field
=
false
;
}
void
set_phase_to_retrieval
()
{
force_return_blank
=
false
;
read_value_from_result_field
=
true
;
}
void
set_read_value_from_result_field
()
{
read_value_from_result_field
=
true
;
...
...
sql/sql_window.cc
View file @
39d3cdbf
...
...
@@ -1590,7 +1590,7 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list)
if
(
item
->
type
()
==
Item
::
WINDOW_FUNC_ITEM
)
{
Item_window_func
*
item_win
=
(
Item_window_func
*
)
item
;
item_win
->
force_return_blank
=
false
;
item_win
->
set_phase_to_computation
()
;
Window_spec
*
spec
=
item_win
->
window_spec
;
/*
The sorting criteria should be
...
...
@@ -1663,7 +1663,7 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list)
DBUG_ASSERT
(
0
);
}
item_win
->
set_
read_value_from_result_field
();
item_win
->
set_
phase_to_retrieval
();
/* This calls filesort_free_buffers(): */
end_read_record
(
&
info
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment