summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorunknown <mhansson/martin@linux-st28.site>2007-12-14 12:24:20 +0100
committerunknown <mhansson/martin@linux-st28.site>2007-12-14 12:24:20 +0100
commit0c4b3f5784fa1af52bd978c1280180c2d659367f (patch)
tree81f9417bf32b62dd7c2c6c6beaa6d374d8b5b1e3 /sql/item_sum.h
parent62a7e160bc0e960ec1374a546dde4a7f26120ceb (diff)
downloadmariadb-git-0c4b3f5784fa1af52bd978c1280180c2d659367f.tar.gz
Bug#32798: DISTINCT in GROUP_CONCAT clause fails when ordering by a column
with null values For queries containing GROUP_CONCAT(DISTINCT fields ORDER BY fields), there was a limitation that the DISTINCT fields had to be the same as ORDER BY fields, owing to the fact that one single sorted tree was used for keeping track of tuples, ordering and uniqueness. Fixed by introducing a second structure to handle uniqueness so that the original structure has only to order the result. mysql-test/r/func_gconcat.result: Bug#32798: - Wrong test result turned correct after fix. - Correct test result mysql-test/t/func_gconcat.test: Bug#32798: Test case sql/item_sum.cc: Bug#32798: Implementation of fix. Dead code removal. - removed comment describing this bug - replaced body of function group_concat_key_cmp_with_distinct - removed function group_concat_key_cmp_with_distinct_and_order - Added a Unique object to maintain uniqueness of values. sql/item_sum.h: Bug#32798: Declarations and comments.
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index d18454cc3b8..bf0abe53eea 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1173,11 +1173,22 @@ class Item_func_group_concat : public Item_sum
String *separator;
TREE tree_base;
TREE *tree;
+
+ /**
+ If DISTINCT is used with this GROUP_CONCAT, this member is used to filter
+ out duplicates.
+ @see Item_func_group_concat::setup
+ @see Item_func_group_concat::add
+ @see Item_func_group_concat::clear
+ */
+ Unique *unique_filter;
TABLE *table;
ORDER **order;
Name_resolution_context *context;
- uint arg_count_order; // total count of ORDER BY items
- uint arg_count_field; // count of arguments
+ /** The number of ORDER BY items. */
+ uint arg_count_order;
+ /** The number of selected items, aka the expr list. */
+ uint arg_count_field;
uint count_cut_values;
bool distinct;
bool warning_for_row;
@@ -1190,13 +1201,10 @@ class Item_func_group_concat : public Item_sum
*/
Item_func_group_concat *original;
- friend int group_concat_key_cmp_with_distinct(void* arg, byte* key1,
- byte* key2);
- friend int group_concat_key_cmp_with_order(void* arg, byte* key1,
- byte* key2);
- friend int group_concat_key_cmp_with_distinct_and_order(void* arg,
- byte* key1,
- byte* key2);
+ friend int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
+ const void* key2);
+ friend int group_concat_key_cmp_with_order(void* arg, const void* key1,
+ const void* key2);
friend int dump_leaf_key(byte* key,
element_count count __attribute__((unused)),
Item_func_group_concat *group_concat_item);
@@ -1207,7 +1215,7 @@ public:
SQL_LIST *is_order, String *is_separator);
Item_func_group_concat(THD *thd, Item_func_group_concat *item);
- ~Item_func_group_concat() {}
+ ~Item_func_group_concat();
void cleanup();
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}