Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: GROUP_CONCAT() function return result set error #938

Closed
2 of 3 tasks
davidshiz opened this issue Nov 15, 2022 · 2 comments · Fixed by #1022
Closed
2 of 3 tasks

bug: GROUP_CONCAT() function return result set error #938

davidshiz opened this issue Nov 15, 2022 · 2 comments · Fixed by #1022
Assignees
Labels
A-bug Something isn't working

Comments

@davidshiz
Copy link
Collaborator

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

GROUP_CONCAT() function, by default, the values of group are separated by (, ) operator,
But here, the result set did not separate by the comma (, ).

The wrong result is as follows:

mysql> select * from test;
+---------------+
| d1            |
+---------------+
|          1234 |
| 1234567890123 |
|      56789012 |
+---------------+
3 rows in set (0.00 sec)
 
 mysql> SELECT group_concat(d1 ORDER BY d1) FROM (SELECT d1 FROM test)a1;
+------------------------------+
| group_concat(d1 ORDER BY d1) |
+------------------------------+
| 1234123456789012356789012    |
+------------------------------+
1 row in set (0.00 sec)

Expected behavior

mysql> SELECT group_concat(d1 ORDER BY d1) FROM (SELECT d1 FROM test)a1;
+------------------------------+
| group_concat(d1 ORDER BY d1) |
+------------------------------+
| 1234,56789012,1234567890123  |
+------------------------------+
1 row in set (0.00 sec)

How To Reproduce

CREATE TABLE test (d1 DECIMAL(17));
INSERT INTO test VALUES
    (1234),     
    (1234567890123),
    (56789012);
SELECT group_concat(d1 ORDER BY d1) FROM (SELECT d1 FROM test)a1;

Environment

root@localhost:/# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: d0c2e01b6
        Last commit time: Date:   Wed Nov 2 19:58:00 2022 +0800
        Build time: Date: Sun 06 Nov 2022 08:50:06 AM UTC
root@ub01:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@davidshiz davidshiz added the A-bug Something isn't working label Nov 15, 2022
@RingsC RingsC self-assigned this Nov 15, 2022
@RingsC
Copy link
Contributor

RingsC commented Nov 28, 2022

using test table directly, the result is ok.

mysql> SELECT group_concat(d1 ORDER BY d1) FROM  test;
+------------------------------+
| group_concat(d1 ORDER BY d1) |
+------------------------------+
| 1234,56789012,1234567890123  |
+------------------------------+
1 row in set (0.00 sec)

@RingsC
Copy link
Contributor

RingsC commented Nov 28, 2022

bool Query::IsAggregationOverFieldItem(Item *item) {
  return IsAggregationItem(item) && IsFieldItem(((Item_sum *)item)->get_arg(0));
}

The type of item is Item_direct_view_ref, and the can not return the right result from IsAggregationOverFieldItem.

Tianmu::core::Query::IsAggregationOverFieldItem (item=0x0) at /home/lihao/workshop/stonedb/storage/tianmu/core/query.cpp:190
190	bool Query::IsAggregationOverFieldItem(Item *item) {
(gdb) n
191	  return IsAggregationItem(item) && IsFieldItem(((Item_sum *)item)->get_arg(0));
(gdb) p IsAggregationItem(item)
$82 = true
(gdb) p ((Item_sum *)item)->get_arg(0)
$83 = (Item_direct_view_ref *) 0x7fa3a0065c60
(gdb) p *((Item_sum *)item)->get_arg(0)
$84 = (Item_direct_view_ref) {
  <Item_direct_ref> = {
    <Item_ref> = {
      <Item_ident> = {
        <Item> = {

@mergify mergify bot closed this as completed in #1022 Nov 29, 2022
mergify bot pushed a commit that referenced this issue Nov 29, 2022
[summary]
To fix up the item which refs to subselect leads `GROUP_CONCAT` wrong result.
The type of item is `REF_ITEM` and therefore, we can not recoginize its type.
konghaiya pushed a commit to konghaiya/stonedb that referenced this issue Mar 7, 2023
…tom#938)

[summary]
To fix up the item which refs to subselect leads `GROUP_CONCAT` wrong result.
The type of item is `REF_ITEM` and therefore, we can not recoginize its type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
None yet
2 participants