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
ee9a19fb
Commit
ee9a19fb
authored
Dec 25, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-21392 Cleanup redundant overriding in Item_sum_num
parent
b21dc119
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
133 deletions
+156
-133
sql/item_sum.cc
sql/item_sum.cc
+1
-21
sql/item_sum.h
sql/item_sum.h
+58
-39
sql/item_windowfunc.h
sql/item_windowfunc.h
+96
-68
sql/sql_window.cc
sql/sql_window.cc
+1
-5
No files found.
sql/item_sum.cc
View file @
ee9a19fb
...
...
@@ -1093,19 +1093,6 @@ void Aggregator_distinct::endup()
}
String
*
Item_sum_num
::
val_str
(
String
*
str
)
{
return
val_string_from_real
(
str
);
}
my_decimal
*
Item_sum_num
::
val_decimal
(
my_decimal
*
decimal_value
)
{
return
val_decimal_from_real
(
decimal_value
);
}
String
*
Item_sum_int
::
val_str
(
String
*
str
)
{
...
...
@@ -2188,7 +2175,7 @@ static double variance_fp_recurrence_result(double s, ulonglong count, bool is_s
Item_sum_variance
::
Item_sum_variance
(
THD
*
thd
,
Item_sum_variance
*
item
)
:
Item_sum_
num
(
thd
,
item
),
Item_sum_
double
(
thd
,
item
),
count
(
item
->
count
),
sample
(
item
->
sample
),
prec_increment
(
item
->
prec_increment
)
{
...
...
@@ -2314,13 +2301,6 @@ double Item_sum_variance::val_real()
}
my_decimal
*
Item_sum_variance
::
val_decimal
(
my_decimal
*
dec_buf
)
{
DBUG_ASSERT
(
fixed
==
1
);
return
val_decimal_from_real
(
dec_buf
);
}
void
Item_sum_variance
::
reset_field
()
{
double
nr
;
...
...
sql/item_sum.h
View file @
ee9a19fb
...
...
@@ -578,6 +578,7 @@ class Item_sum :public Item_func_or_sum
void
mark_as_window_func_sum_expr
()
{
window_func_sum_expr_flag
=
true
;
}
bool
is_window_func_sum_expr
()
{
return
window_func_sum_expr_flag
;
}
virtual
void
setup_caches
(
THD
*
thd
)
{};
virtual
void
set_partition_row_count
(
ulonglong
count
)
{
DBUG_ASSERT
(
0
);
}
};
...
...
@@ -713,33 +714,45 @@ class Aggregator_simple : public Aggregator
class
Item_sum_num
:
public
Item_sum
{
protected:
/*
val_xxx() functions may be called several times during the execution of a
query. Derived classes that require extensive calculation in val_xxx()
maintain cache of aggregate value. This variable governs the validity of
that cache.
*/
bool
is_evaluated
;
public:
Item_sum_num
(
THD
*
thd
)
:
Item_sum
(
thd
)
,
is_evaluated
(
FALSE
)
{}
Item_sum_num
(
THD
*
thd
)
:
Item_sum
(
thd
)
{}
Item_sum_num
(
THD
*
thd
,
Item
*
item_par
)
:
Item_sum
(
thd
,
item_par
)
,
is_evaluated
(
FALSE
)
{}
Item_sum
(
thd
,
item_par
)
{}
Item_sum_num
(
THD
*
thd
,
Item
*
a
,
Item
*
b
)
:
Item_sum
(
thd
,
a
,
b
)
,
is_evaluated
(
FALSE
)
{}
Item_sum
(
thd
,
a
,
b
)
{}
Item_sum_num
(
THD
*
thd
,
List
<
Item
>
&
list
)
:
Item_sum
(
thd
,
list
)
,
is_evaluated
(
FALSE
)
{}
Item_sum
(
thd
,
list
)
{}
Item_sum_num
(
THD
*
thd
,
Item_sum_num
*
item
)
:
Item_sum
(
thd
,
item
)
,
is_evaluated
(
item
->
is_evaluated
)
{}
Item_sum
(
thd
,
item
)
{}
bool
fix_fields
(
THD
*
,
Item
**
);
longlong
val_int
()
{
return
val_int_from_real
();
/* Real as default */
}
String
*
val_str
(
String
*
str
);
my_decimal
*
val_decimal
(
my_decimal
*
);
void
reset_field
();
};
class
Item_sum_double
:
public
Item_sum_num
{
public:
Item_sum_double
(
THD
*
thd
)
:
Item_sum_num
(
thd
)
{}
Item_sum_double
(
THD
*
thd
,
Item
*
item_par
)
:
Item_sum_num
(
thd
,
item_par
)
{}
Item_sum_double
(
THD
*
thd
,
List
<
Item
>
&
list
)
:
Item_sum_num
(
thd
,
list
)
{}
Item_sum_double
(
THD
*
thd
,
Item_sum_double
*
item
)
:
Item_sum_num
(
thd
,
item
)
{}
longlong
val_int
()
{
return
val_int_from_real
();
}
String
*
val_str
(
String
*
str
)
{
return
val_string_from_real
(
str
);
}
my_decimal
*
val_decimal
(
my_decimal
*
to
)
{
return
val_decimal_from_real
(
to
);
}
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
return
type_handler
()
->
Item_get_date
(
this
,
ltime
,
fuzzydate
);
return
get_date_from_real
(
ltime
,
fuzzydate
);
}
void
reset_field
();
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_double
;
}
};
...
...
@@ -753,6 +766,10 @@ class Item_sum_int :public Item_sum_num
double
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
return
(
double
)
val_int
();
}
String
*
val_str
(
String
*
str
);
my_decimal
*
val_decimal
(
my_decimal
*
);
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
return
get_date_from_int
(
ltime
,
fuzzydate
);
}
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_longlong
;
}
bool
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
21
;
maybe_null
=
null_value
=
0
;
return
FALSE
;
}
...
...
@@ -794,6 +811,10 @@ class Item_sum_sum :public Item_sum_num,
longlong
val_int
();
String
*
val_str
(
String
*
str
);
my_decimal
*
val_decimal
(
my_decimal
*
);
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzydate
)
{
return
type_handler
()
->
Item_get_date
(
this
,
ltime
,
fuzzydate
);
}
const
Type_handler
*
type_handler
()
const
{
return
Type_handler_hybrid_field_type
::
type_handler
();
}
void
fix_length_and_dec_double
();
...
...
@@ -964,7 +985,7 @@ But, this falls prey to catastrophic cancellation. Instead, use the recurrence
*/
class
Item_sum_variance
:
public
Item_sum_
num
class
Item_sum_variance
:
public
Item_sum_
double
{
bool
fix_length_and_dec
();
...
...
@@ -975,7 +996,7 @@ class Item_sum_variance : public Item_sum_num
uint
prec_increment
;
Item_sum_variance
(
THD
*
thd
,
Item
*
item_par
,
uint
sample_arg
)
:
Item_sum_
num
(
thd
,
item_par
),
count
(
0
),
Item_sum_
double
(
thd
,
item_par
),
count
(
0
),
sample
(
sample_arg
)
{}
Item_sum_variance
(
THD
*
thd
,
Item_sum_variance
*
item
);
...
...
@@ -985,7 +1006,6 @@ class Item_sum_variance : public Item_sum_num
void
clear
();
bool
add
();
double
val_real
();
my_decimal
*
val_decimal
(
my_decimal
*
);
void
reset_field
();
void
update_field
();
Item
*
result_item
(
THD
*
thd
,
Field
*
field
);
...
...
@@ -994,11 +1014,10 @@ class Item_sum_variance : public Item_sum_num
{
return
sample
?
"var_samp("
:
"variance("
;
}
Item
*
copy_or_same
(
THD
*
thd
);
Field
*
create_tmp_field
(
bool
group
,
TABLE
*
table
);
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_double
;
}
void
cleanup
()
{
count
=
0
;
Item_sum_
num
::
cleanup
();
Item_sum_
double
::
cleanup
();
}
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_sum_variance
>
(
thd
,
this
);
}
...
...
@@ -1679,15 +1698,15 @@ class Item_sum_udf_decimal :public Item_udf_sum
#else
/* Dummy functions to get sql_yacc.cc compiled */
class
Item_sum_udf_float
:
public
Item_sum_
num
class
Item_sum_udf_float
:
public
Item_sum_
double
{
public:
Item_sum_udf_float
(
THD
*
thd
,
udf_func
*
udf_arg
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_float
(
THD
*
thd
,
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_float
(
THD
*
thd
,
Item_sum_udf_float
*
item
)
:
Item_sum_
num
(
thd
,
item
)
{}
:
Item_sum_
double
(
thd
,
item
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
UDF_SUM_FUNC
;
}
double
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
return
0.0
;
}
void
clear
()
{}
...
...
@@ -1696,15 +1715,15 @@ class Item_sum_udf_float :public Item_sum_num
};
class
Item_sum_udf_int
:
public
Item_sum_
num
class
Item_sum_udf_int
:
public
Item_sum_
double
{
public:
Item_sum_udf_int
(
THD
*
thd
,
udf_func
*
udf_arg
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_int
(
THD
*
thd
,
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_int
(
THD
*
thd
,
Item_sum_udf_int
*
item
)
:
Item_sum_
num
(
thd
,
item
)
{}
:
Item_sum_
double
(
thd
,
item
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
UDF_SUM_FUNC
;
}
longlong
val_int
()
{
DBUG_ASSERT
(
fixed
==
1
);
return
0
;
}
double
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
return
0
;
}
...
...
@@ -1714,15 +1733,15 @@ class Item_sum_udf_int :public Item_sum_num
};
class
Item_sum_udf_decimal
:
public
Item_sum_
num
class
Item_sum_udf_decimal
:
public
Item_sum_
double
{
public:
Item_sum_udf_decimal
(
THD
*
thd
,
udf_func
*
udf_arg
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_decimal
(
THD
*
thd
,
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_decimal
(
THD
*
thd
,
Item_sum_udf_float
*
item
)
:
Item_sum_
num
(
thd
,
item
)
{}
:
Item_sum_
double
(
thd
,
item
)
{}
enum
Sumfunctype
sum_func
()
const
{
return
UDF_SUM_FUNC
;
}
double
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
return
0.0
;
}
my_decimal
*
val_decimal
(
my_decimal
*
)
{
DBUG_ASSERT
(
fixed
==
1
);
return
0
;
}
...
...
@@ -1732,15 +1751,15 @@ class Item_sum_udf_decimal :public Item_sum_num
};
class
Item_sum_udf_str
:
public
Item_sum_
num
class
Item_sum_udf_str
:
public
Item_sum_
double
{
public:
Item_sum_udf_str
(
THD
*
thd
,
udf_func
*
udf_arg
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_str
(
THD
*
thd
,
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_sum_
num
(
thd
)
{}
Item_sum_
double
(
thd
)
{}
Item_sum_udf_str
(
THD
*
thd
,
Item_sum_udf_str
*
item
)
:
Item_sum_
num
(
thd
,
item
)
{}
:
Item_sum_
double
(
thd
,
item
)
{}
String
*
val_str
(
String
*
)
{
DBUG_ASSERT
(
fixed
==
1
);
null_value
=
1
;
return
0
;
}
double
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
null_value
=
1
;
return
0.0
;
}
...
...
sql/item_windowfunc.h
View file @
ee9a19fb
This diff is collapsed.
Click to expand it.
sql/sql_window.cc
View file @
ee9a19fb
...
...
@@ -1779,11 +1779,7 @@ class Frame_unbounded_following_set_count : public Frame_unbounded_following
List_iterator_fast
<
Item_sum
>
it
(
sum_functions
);
Item_sum
*
item
;
while
((
item
=
it
++
))
{
Item_sum_window_with_row_count
*
item_with_row_count
=
static_cast
<
Item_sum_window_with_row_count
*>
(
item
);
item_with_row_count
->
set_row_count
(
num_rows_in_partition
);
}
item
->
set_partition_row_count
(
num_rows_in_partition
);
}
};
...
...
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