MySQL 8.0.40
Source Code Documentation
|
Sum functions (COUNT, MIN...) More...
#include "sql/item_sum.h"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <functional>
#include <optional>
#include <string>
#include <utility>
#include "decimal.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_byteorder.h"
#include "my_compare.h"
#include "my_dbug.h"
#include "my_double2ulonglong.h"
#include "my_sys.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql-common/json_dom.h"
#include "sql/aggregate_check.h"
#include "sql/create_field.h"
#include "sql/current_thd.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/gis/gc_utils.h"
#include "sql/gis/geometries.h"
#include "sql/gis/geometry_extraction.h"
#include "sql/gis/relops.h"
#include "sql/handler.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_func.h"
#include "sql/item_json_func.h"
#include "sql/item_subselect.h"
#include "sql/key_spec.h"
#include "sql/mysqld.h"
#include "sql/parse_tree_helpers.h"
#include "sql/parse_tree_node_base.h"
#include "sql/parse_tree_nodes.h"
#include "sql/parser_yystype.h"
#include "sql/sql_array.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
#include "sql/sql_exception_handler.h"
#include "sql/sql_executor.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_optimizer.h"
#include "sql/sql_resolver.h"
#include "sql/sql_select.h"
#include "sql/sql_tmp_table.h"
#include "sql/srs_fetcher.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/temp_table_param.h"
#include "sql/uniques.h"
#include "sql/window.h"
Namespaces | |
namespace | anonymous_namespace{item_sum.cc} |
Functions | |
static int | simple_str_key_cmp (const void *arg, const void *a, const void *b) |
Compare keys consisting of single field that cannot be compared as binary. More... | |
static enum enum_field_types | calc_tmp_field_type (enum enum_field_types table_field_type, Item_result result_type) |
static int | simple_raw_key_cmp (const void *arg, const void *key1, const void *key2) |
static int | item_sum_distinct_walk (void *element, element_count, void *item) |
template<class Char_op , class Int_op > | |
static void | apply_bit_op (size_t buff_length, const uchar *s1_c_p, uchar *value_bits) |
Helper for Item_sum_bit::add_bits(). More... | |
static void | add_sample (double *m, double *s, double *s2, ulonglong *count, double nr) |
Calculates the next recurrence value s,s2 using the current sample as input. More... | |
static void | remove_sample (double *m, double *s, double *s2, ulonglong *count, double nr) |
Removes the earlier calculated recurrence value s,s2 for current sample from the current s,s2 values. More... | |
static bool | variance_fp_recurrence_next (Item_sum_variance *self, double *m, double *s, double *s2, ulonglong *count, double nr, bool optimize, bool inverse) |
Calculates the next recurrence value for current sample. More... | |
static double | variance_fp_recurrence_result (double s, double s2, ulonglong count, bool is_sample_variance, bool optimize) |
Calculates variance using one of the two algorithms (See Item_sum_variance) as specified. More... | |
static bool | min_max_best_so_far (int comparison_result, bool is_min) |
Checks if a value should replace the minimum or maximum value seen so far in the MIN and MAX aggregate functions. More... | |
int | group_concat_key_cmp_with_distinct (const void *arg, const void *key1, const void *key2) |
Compares the values for fields in expr list of GROUP_CONCAT. More... | |
int | group_concat_key_cmp_with_order (const void *arg, const void *key1, const void *key2) |
function of sort for syntax: GROUP_CONCAT(expr,... ORDER BY col,... ) More... | |
int | dump_leaf_key (void *key_arg, element_count count, void *item_arg) |
Append data from current leaf to item->result. More... | |
std::unique_ptr< gis::Geometrycollection > | anonymous_namespace{item_sum.cc}::filtergeometries (std::unique_ptr< gis::Geometrycollection > geometrycollection, const dd::Spatial_reference_system *srs) |
Sum functions (COUNT, MIN...)
|
static |
Calculates the next recurrence value s,s2 using the current sample as input.
m is initialized to the first sample. Its not changed for the later calls.
[in,out] | m | recurrence value |
[in,out] | s | recurrence value |
[in,out] | s2 | Square of the recurrence value s |
[in,out] | count | Number of rows for which m,s,s2 is calculated |
[in] | nr | Current sample |
|
inlinestatic |
Helper for Item_sum_bit::add_bits().
Does value_bits = s1_c_p bit_op value_bits.
Char_op | class offering a bit operation for a uchar: AND, OR or XOR |
Int_op | class offering a bit operation for a ulonglong: ditto |
buff_length | length of s1_c_p | |
s1_c_p | first argument of bit op | |
[in,out] | value_bits | second argument of bit op, and result |
|
static |
int dump_leaf_key | ( | void * | key_arg, |
element_count | count, | ||
void * | item_arg | ||
) |
Append data from current leaf to item->result.
To avoid duplicated warnings in Item_func_group_concat::val_str()
int group_concat_key_cmp_with_distinct | ( | const void * | arg, |
const void * | key1, | ||
const void * | key2 | ||
) |
Compares the values for fields in expr list of GROUP_CONCAT.
-1 | : key1 < key2 |
0 | : key1 = key2 |
1 | : key1 > key2 |
int group_concat_key_cmp_with_order | ( | const void * | arg, |
const void * | key1, | ||
const void * | key2 | ||
) |
function of sort for syntax: GROUP_CONCAT(expr,... ORDER BY col,... )
|
static |
|
static |
Checks if a value should replace the minimum or maximum value seen so far in the MIN and MAX aggregate functions.
comparison_result | the result of comparing the current value with the min/max value seen so far (negative if it's smaller, 0 if it's equal, positive if it's greater) |
is_min | true if called by MIN, false if called by MAX |
|
static |
Removes the earlier calculated recurrence value s,s2 for current sample from the current s,s2 values.
Called when do_inverse() is true.
[in] | m | recurrence value |
[in,out] | s | recurrence value |
[in,out] | s2 | Square of the recurrence value s |
[in,out] | count | Number of rows for which s,s2 is calculated |
[in] | nr | Current sample |
|
static |
|
static |
Compare keys consisting of single field that cannot be compared as binary.
Used by the Unique class to compare keys. Will do correct comparisons for all field types.
arg | Pointer to the relevant Field class instance |
a | left key image |
b | right key image |
< | 0 if key1 < key2 |
= | 0 if key1 = key2 |
> | 0 if key1 > key2 |
|
static |
Calculates the next recurrence value for current sample.
[in] | self | The object on which behalf we are computing |
[in,out] | m | recurrence value |
[in,out] | s | recurrence value |
[in,out] | s2 | Square of the recurrence value s |
[in,out] | count | Number of rows for which m,s,s2 is calculated |
[in] | nr | Current sample |
[in] | optimize | If set to true is Algorithm II is used to calculate m,s and s2. Else Algorithm I is used to calculate m,s. |
[in] | inverse | If set to true, we use formulas from Algorithm II to remove value calculated for s,s2 for sample "nr" from the the current value of (s,s2). |
Note: variance_fp_recurrence_next and variance_fp_recurrence_result are used by Item_sum_variance and Item_variance_field classes, which are unrelated, and each need to calculate variance. The difference between the two classes is that the first is used for a mundane SELECT and when used with windowing functions, while the latter is used in a GROUPing SELECT.
|
static |
Calculates variance using one of the two algorithms (See Item_sum_variance) as specified.
[in] | s | Recurrence value |
[in] | s2 | Square of the recurrence value. Used only by Algorithm II |
[in] | count | Number of rows for which variance needs to be calculated. |
[in] | is_sample_variance | True if calculating sample variance and false if population variance. |
[in] | optimize | True if algorithm II is used to calculate variance. |
Returns | calculated variance value |