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
7c9cfa07
Commit
7c9cfa07
authored
Apr 05, 2016
by
Vicențiu Ciorbaru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ntile to work with --ps-protocol
parent
9bd194b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
sql/item_windowfunc.h
sql/item_windowfunc.h
+11
-11
No files found.
sql/item_windowfunc.h
View file @
7c9cfa07
...
...
@@ -403,7 +403,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
public:
Item_sum_ntile
(
THD
*
thd
,
Item
*
num_quantiles_expr
)
:
Item_sum_window_with_row_count
(
thd
,
num_quantiles_expr
),
num_quantiles_expr_
(
num_quantiles_expr
),
num_quantiles_
(
0
),
num_quantiles_expr_
(
num_quantiles_expr
),
current_row_count_
(
0
)
{};
double
val_real
()
...
...
@@ -418,9 +418,17 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
null_value
=
true
;
return
0
;
}
longlong
num_quantiles
=
num_quantiles_expr_
->
val_int
();
if
(
num_quantiles
<=
0
)
{
my_error
(
ER_INVALID_NTILE_ARGUMENT
,
MYF
(
0
));
return
true
;
}
null_value
=
false
;
ulonglong
quantile_size
=
get_row_count
()
/
num_quantiles
_
;
ulonglong
extra_rows
=
get_row_count
()
-
quantile_size
*
num_quantiles
_
;
ulonglong
quantile_size
=
get_row_count
()
/
num_quantiles
;
ulonglong
extra_rows
=
get_row_count
()
-
quantile_size
*
num_quantiles
;
if
(
current_row_count_
<=
extra_rows
*
(
quantile_size
+
1
))
return
(
current_row_count_
-
1
)
/
(
quantile_size
+
1
)
+
1
;
...
...
@@ -462,20 +470,12 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
// TODO-cvicentiu is ref as a parameter here ok?
if
(
!
num_quantiles_expr_
->
fixed
)
num_quantiles_expr_
->
fix_fields
(
thd
,
ref
);
longlong
expr_value
=
num_quantiles_expr_
->
val_int
();
if
(
expr_value
<=
0
)
{
my_error
(
ER_INVALID_NTILE_ARGUMENT
,
MYF
(
0
));
return
true
;
}
num_quantiles_
=
static_cast
<
ulong
>
(
expr_value
);
return
false
;
}
private:
Item
*
num_quantiles_expr_
;
ulong
num_quantiles_
;
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