mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Implementation of SUM(DISTINCT), tests cases
sql/filesort.cc: Snippet of filesort() code moved to function reuse_freed_buff() - change buffpek pointers to use buff from freed BUFFPEK Used in filesort() and merge_walk(). sql/item_sum.cc: Implementation of Item_sum_sum_distinct - SUM(DISTINCT) item, which uses Unique to resolve duplicates sql/item_sum.h: New sum Item added - Item_sum_sum_distinct - for SUM(DISTINCT) function sql/sql_class.h: added walk() and reset() methods to Unique, used in Item_sum_sum_distinct. sql/sql_sort.h: declaration for reuse_freed_buff() to be able to use it in uniques.cc sql/sql_yacc.yy: parser extended to handle MIN(DISTICNT), MAX(DISTINCT), SUM(DISTINCT) sql/uniques.cc: Implementation for Unique::reset(), Unique::walk() as well as for merge_walk() algorithm.
This commit is contained in:
@ -1207,8 +1207,13 @@ class user_var_entry
|
||||
DTCollation collation;
|
||||
};
|
||||
|
||||
|
||||
/* Class for unique (removing of duplicates) */
|
||||
/*
|
||||
Unique -- class for unique (removing of duplicates).
|
||||
Puts all values to the TREE. If the tree becomes too big,
|
||||
it's dumped to the file. User can request sorted values, or
|
||||
just iterate through them. In the last case tree merging is performed in
|
||||
memory simultaneously with iteration, so it should be ~2-3x faster.
|
||||
*/
|
||||
|
||||
class Unique :public Sql_alloc
|
||||
{
|
||||
@ -1222,10 +1227,10 @@ class Unique :public Sql_alloc
|
||||
|
||||
public:
|
||||
ulong elements;
|
||||
Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
|
||||
Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
|
||||
uint size_arg, ulong max_in_memory_size_arg);
|
||||
~Unique();
|
||||
inline bool unique_add(gptr ptr)
|
||||
inline bool unique_add(void *ptr)
|
||||
{
|
||||
if (tree.elements_in_tree > max_elements && flush())
|
||||
return 1;
|
||||
@ -1234,6 +1239,9 @@ public:
|
||||
|
||||
bool get(TABLE *table);
|
||||
|
||||
void reset();
|
||||
bool walk(tree_walk_action action, void *walk_action_arg);
|
||||
|
||||
friend int unique_write_to_file(gptr key, element_count count, Unique *unique);
|
||||
friend int unique_write_to_ptrs(gptr key, element_count count, Unique *unique);
|
||||
};
|
||||
|
Reference in New Issue
Block a user