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
bc6df8d6
Commit
bc6df8d6
authored
Apr 14, 2016
by
Igor Babaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bb-10.2-mdev9543' of github.com:MariaDB/server into bb-10.2-mdev9543
parents
5ff4b21e
31fb045c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
22 deletions
+15
-22
mysql-test/r/win_rank.result
mysql-test/r/win_rank.result
+5
-5
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+4
-1
sql/item_windowfunc.h
sql/item_windowfunc.h
+6
-16
No files found.
mysql-test/r/win_rank.result
View file @
bc6df8d6
...
@@ -40,11 +40,11 @@ pk a b rank dense_rank
...
@@ -40,11 +40,11 @@ pk a b rank dense_rank
3 1 10 3 2
3 1 10 3 2
4 1 10 3 2
4 1 10 3 2
8 2 10 5 3
8 2 10 5 3
5 2 20 1
0
5 2 20 1
1
6 2 20 1
0
6 2 20 1
1
7 2 20 1
0
7 2 20 1
1
9 4 20 4
1
9 4 20 4
2
10 4 20 4
1
10 4 20 4
2
drop table t1;
drop table t1;
#
#
# Test with null values in the table.
# Test with null values in the table.
...
...
sql/item_windowfunc.cc
View file @
bc6df8d6
...
@@ -185,8 +185,11 @@ void Item_sum_dense_rank::setup_window_func(THD *thd, Window_spec *window_spec)
...
@@ -185,8 +185,11 @@ void Item_sum_dense_rank::setup_window_func(THD *thd, Window_spec *window_spec)
bool
Item_sum_dense_rank
::
add
()
bool
Item_sum_dense_rank
::
add
()
{
{
if
(
peer_tracker
.
check_if_next_group
())
if
(
peer_tracker
.
check_if_next_group
()
||
first_add
)
{
first_add
=
false
;
dense_rank
++
;
dense_rank
++
;
}
return
false
;
return
false
;
}
}
...
...
sql/item_windowfunc.h
View file @
bc6df8d6
...
@@ -213,7 +213,9 @@ class Item_sum_rank: public Item_sum_int
...
@@ -213,7 +213,9 @@ class Item_sum_rank: public Item_sum_int
class
Item_sum_dense_rank
:
public
Item_sum_int
class
Item_sum_dense_rank
:
public
Item_sum_int
{
{
longlong
dense_rank
;
longlong
dense_rank
;
bool
first_add
;
Group_bound_tracker
peer_tracker
;
Group_bound_tracker
peer_tracker
;
public:
/*
/*
XXX(cvicentiu) This class could potentially be implemented in the rank
XXX(cvicentiu) This class could potentially be implemented in the rank
class, with a switch for the DENSE case.
class, with a switch for the DENSE case.
...
@@ -221,6 +223,7 @@ class Item_sum_dense_rank: public Item_sum_int
...
@@ -221,6 +223,7 @@ class Item_sum_dense_rank: public Item_sum_int
void
clear
()
void
clear
()
{
{
dense_rank
=
0
;
dense_rank
=
0
;
first_add
=
true
;
}
}
bool
add
();
bool
add
();
void
update_field
()
{}
void
update_field
()
{}
...
@@ -229,9 +232,8 @@ class Item_sum_dense_rank: public Item_sum_int
...
@@ -229,9 +232,8 @@ class Item_sum_dense_rank: public Item_sum_int
return
dense_rank
;
return
dense_rank
;
}
}
public:
Item_sum_dense_rank
(
THD
*
thd
)
Item_sum_dense_rank
(
THD
*
thd
)
:
Item_sum_int
(
thd
),
dense_rank
(
0
)
{}
:
Item_sum_int
(
thd
),
dense_rank
(
0
)
,
first_add
(
true
)
{}
enum
Sumfunctype
sum_func
()
const
enum
Sumfunctype
sum_func
()
const
{
{
return
DENSE_RANK_FUNC
;
return
DENSE_RANK_FUNC
;
...
@@ -427,7 +429,6 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
...
@@ -427,7 +429,6 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
public:
public:
Item_sum_ntile
(
THD
*
thd
,
Item
*
num_quantiles_expr
)
:
Item_sum_ntile
(
THD
*
thd
,
Item
*
num_quantiles_expr
)
:
Item_sum_window_with_row_count
(
thd
,
num_quantiles_expr
),
Item_sum_window_with_row_count
(
thd
,
num_quantiles_expr
),
num_quantiles_expr_
(
num_quantiles_expr
),
current_row_count_
(
0
)
{};
current_row_count_
(
0
)
{};
double
val_real
()
double
val_real
()
...
@@ -443,7 +444,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
...
@@ -443,7 +444,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
return
0
;
return
0
;
}
}
longlong
num_quantiles
=
num_quantiles_expr_
->
val_int
();
longlong
num_quantiles
=
get_num_quantiles
();
if
(
num_quantiles
<=
0
)
{
if
(
num_quantiles
<=
0
)
{
my_error
(
ER_INVALID_NTILE_ARGUMENT
,
MYF
(
0
));
my_error
(
ER_INVALID_NTILE_ARGUMENT
,
MYF
(
0
));
...
@@ -487,19 +488,8 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
...
@@ -487,19 +488,8 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
enum
Item_result
result_type
()
const
{
return
INT_RESULT
;
}
enum
Item_result
result_type
()
const
{
return
INT_RESULT
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_LONGLONG
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_LONGLONG
;
}
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
)
{
if
(
Item_sum_window_with_row_count
::
fix_fields
(
thd
,
ref
))
return
true
;
// TODO-cvicentiu is ref as a parameter here ok?
if
(
!
num_quantiles_expr_
->
fixed
)
num_quantiles_expr_
->
fix_fields
(
thd
,
ref
);
return
false
;
}
private:
private:
Item
*
num_quantiles_expr_
;
longlong
get_num_quantiles
()
{
return
args
[
0
]
->
val_int
();
}
ulong
current_row_count_
;
ulong
current_row_count_
;
};
};
...
...
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