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
dedf87fd
Commit
dedf87fd
authored
Mar 02, 2016
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename window frame start/end to top/bottom. Bikeshed should be green.
parent
7ee01401
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
34 deletions
+34
-34
sql/sql_window.cc
sql/sql_window.cc
+34
-34
No files found.
sql/sql_window.cc
View file @
dedf87fd
...
...
@@ -358,7 +358,7 @@ class Frame_unbounded_preceding : public Frame_cursor
{
/*
UNBOUNDED PRECEDING frame end just stays on the first row.
We are
start
of the frame, so we don't need to update the sum function.
We are
top
of the frame, so we don't need to update the sum function.
*/
}
...
...
@@ -418,8 +418,8 @@ class Frame_unbounded_following : public Frame_cursor
class
Frame_n_rows
:
public
Frame_cursor
{
/* Whether this
start of frame or end of rame */
const
bool
is_
start
;
/* Whether this
is top of the frame or bottom */
const
bool
is_
top_bound
;
const
ha_rows
n_rows
;
const
bool
is_preceding
;
...
...
@@ -432,8 +432,8 @@ class Frame_n_rows : public Frame_cursor
bool
at_partition_start
;
bool
at_partition_end
;
public:
Frame_n_rows
(
bool
is_
start
_arg
,
bool
is_preceding_arg
,
ha_rows
n_rows_arg
)
:
is_
start
(
is_start
_arg
),
n_rows
(
n_rows_arg
),
is_preceding
(
is_preceding_arg
)
Frame_n_rows
(
bool
is_
top_bound
_arg
,
bool
is_preceding_arg
,
ha_rows
n_rows_arg
)
:
is_
top_bound
(
is_top_bound
_arg
),
n_rows
(
n_rows_arg
),
is_preceding
(
is_preceding_arg
)
{}
void
init
(
THD
*
thd
,
READ_RECORD
*
info
,
SQL_I_List
<
ORDER
>
*
partition_list
)
...
...
@@ -464,7 +464,7 @@ class Frame_n_rows : public Frame_cursor
break
;
}
}
n_rows_to_skip
=
n_rows
-
(
is_
start
?
0
:
1
);
n_rows_to_skip
=
n_rows
-
(
is_
top_bound
?
0
:
1
);
}
else
{
...
...
@@ -474,19 +474,19 @@ class Frame_n_rows : public Frame_cursor
*/
n_rows_to_skip
=
0
;
if
(
!
first
&&
(
!
is_
start
||
n_rows
))
if
(
!
first
&&
(
!
is_
top_bound
||
n_rows
))
{
// We are positioned at the first row in the partition:
if
(
is_
start
)
// this is frame start
endpoint
if
(
is_
top_bound
)
// this is frame top
endpoint
item
->
remove
();
else
item
->
add
();
}
/*
Note: i_end=-1 when this is a
start
-endpoint "CURRENT ROW" which is
Note: i_end=-1 when this is a
top
-endpoint "CURRENT ROW" which is
implemented as "ROWS 0 FOLLOWING".
*/
longlong
i_end
=
n_rows
+
(
first
?
1
:
0
)
-
is_
start
;
longlong
i_end
=
n_rows
+
(
first
?
1
:
0
)
-
is_
top_bound
;
for
(
longlong
i
=
0
;
i
<
i_end
;
i
++
)
{
if
(
next_row_intern
(
item
))
...
...
@@ -517,7 +517,7 @@ class Frame_n_rows : public Frame_cursor
bool
new_group
=
bound_tracker
.
check_if_next_group
();
if
(
at_partition_start
||
!
new_group
)
{
if
(
is_
start
)
// this is frame start endpoint
if
(
is_
top_bound
)
// this is frame start endpoint
item
->
remove
();
else
item
->
add
();
...
...
@@ -541,13 +541,13 @@ class Frame_n_rows : public Frame_cursor
class
Frame_current_row
:
public
Frame_n_rows
{
public:
Frame_current_row
(
bool
is_
start
_arg
)
:
Frame_n_rows
(
is_
start
_arg
,
false
/*is_preceding*/
,
ha_rows
(
0
))
Frame_current_row
(
bool
is_
top_bound
_arg
)
:
Frame_n_rows
(
is_
top_bound
_arg
,
false
/*is_preceding*/
,
ha_rows
(
0
))
{}
};
Frame_cursor
*
get_frame_cursor
(
Window_frame_bound
*
bound
,
bool
is_
start
_bound
)
Frame_cursor
*
get_frame_cursor
(
Window_frame_bound
*
bound
,
bool
is_
top
_bound
)
{
if
(
bound
->
precedence_type
==
Window_frame_bound
::
PRECEDING
||
bound
->
precedence_type
==
Window_frame_bound
::
FOLLOWING
)
...
...
@@ -564,12 +564,12 @@ Frame_cursor *get_frame_cursor(Window_frame_bound *bound, bool is_start_bound)
}
longlong
n_rows
=
bound
->
offset
->
val_int
();
return
new
Frame_n_rows
(
is_
start
_bound
,
is_preceding
,
n_rows
);
return
new
Frame_n_rows
(
is_
top
_bound
,
is_preceding
,
n_rows
);
}
if
(
bound
->
precedence_type
==
Window_frame_bound
::
CURRENT
)
{
return
new
Frame_current_row
(
is_
start
_bound
);
return
new
Frame_current_row
(
is_
top
_bound
);
}
return
NULL
;
}
...
...
@@ -582,7 +582,7 @@ Frame_cursor *get_frame_cursor(Window_frame_bound *bound, bool is_start_bound)
cursors:
- current row - the row that we're computing window func value for)
- start_bound - the start of the frame
-
end
_bound - the end of the frame
-
bottom
_bound - the end of the frame
All three cursors move together.
...
...
@@ -616,8 +616,8 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
{
THD
*
thd
=
current_thd
;
int
err
=
0
;
Frame_cursor
*
start
_bound
;
Frame_cursor
*
end
_bound
;
Frame_cursor
*
top
_bound
;
Frame_cursor
*
bottom
_bound
;
Item_sum
*
sum_func
=
item_win
->
window_func
;
/* This algorithm doesn't support DISTINCT aggregator */
...
...
@@ -625,11 +625,11 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
Window_frame
*
window_frame
=
item_win
->
window_spec
->
window_frame
;
DBUG_ASSERT
(
window_frame
->
units
==
Window_frame
::
UNITS_ROWS
);
start
_bound
=
get_frame_cursor
(
window_frame
->
top_bound
,
true
);
end
_bound
=
get_frame_cursor
(
window_frame
->
bottom_bound
,
false
);
top
_bound
=
get_frame_cursor
(
window_frame
->
top_bound
,
true
);
bottom
_bound
=
get_frame_cursor
(
window_frame
->
bottom_bound
,
false
);
start
_bound
->
init
(
thd
,
info
,
&
item_win
->
window_spec
->
partition_list
);
end
_bound
->
init
(
thd
,
info
,
&
item_win
->
window_spec
->
partition_list
);
top
_bound
->
init
(
thd
,
info
,
&
item_win
->
window_spec
->
partition_list
);
bottom
_bound
->
init
(
thd
,
info
,
&
item_win
->
window_spec
->
partition_list
);
bool
is_error
=
false
;
bool
first_row
=
true
;
...
...
@@ -641,14 +641,14 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
{
/* Start the first partition */
sum_func
->
clear
();
end
_bound
->
next_partition
(
true
,
sum_func
);
start
_bound
->
next_partition
(
true
,
sum_func
);
bottom
_bound
->
next_partition
(
true
,
sum_func
);
top
_bound
->
next_partition
(
true
,
sum_func
);
}
else
{
/* These can write into tbl->record[0] */
end
_bound
->
next_row
(
sum_func
);
start
_bound
->
next_row
(
sum_func
);
bottom
_bound
->
next_row
(
sum_func
);
top
_bound
->
next_row
(
sum_func
);
}
if
((
err
=
info
->
read_record
(
info
)))
...
...
@@ -667,17 +667,17 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
memcpy
(
rowid_buf
,
tbl
->
file
->
ref
,
tbl
->
file
->
ref_length
);
/*
Ok, the current row is the first row in the new partition.
We move
end
_bound first, because we want rows to be added into the
aggregate before
start
_bound attempts to remove them.
We move
bottom
_bound first, because we want rows to be added into the
aggregate before
top
_bound attempts to remove them.
*/
end
_bound
->
next_partition
(
false
,
sum_func
);
bottom
_bound
->
next_partition
(
false
,
sum_func
);
/*
The problem is, the above call may have made tbl->record[0] to point to
some other record.
*/
tbl
->
file
->
ha_rnd_pos
(
tbl
->
record
[
0
],
rowid_buf
);
start
_bound
->
next_partition
(
false
,
sum_func
);
top
_bound
->
next_partition
(
false
,
sum_func
);
/*
The same problem again. The above call may have moved table's current
...
...
@@ -699,8 +699,8 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
}
my_free
(
rowid_buf
);
delete
start
_bound
;
delete
end
_bound
;
delete
top
_bound
;
delete
bottom
_bound
;
return
is_error
?
true
:
false
;
}
...
...
@@ -906,7 +906,7 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list)
{
/*
Frame-aware window function computation. It does one pass, but
uses three cursors -frame_
start, current_row, and frame_end
.
uses three cursors -frame_
top, current_row, and frame_bottom
.
*/
if
(
compute_window_func_with_frames
(
item_win
,
tbl
,
&
info
))
is_error
=
true
;
...
...
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