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

select count(1) with group by statement return one row when there is actual no data #33209

Closed
peacefulprogram opened this issue Oct 11, 2024 · 4 comments

Comments

@peacefulprogram
Copy link

Which version of ShardingSphere did you use?

5.5.0

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

both ShardingSphere-JDBC and ShardingSphere-Proxy

Reproduce

enviroment:
mysql 5.7
shardingsphere 5.5.0
table:
t_user

the following two sql, only the order by statement is differenet, but have diffenrent result;

  1. order by fields is same with group by fields, returns no data
    image

  2. order by fields is different from group by fields, returns one row
    image

they both should returns no data;

Reason analyze

when order by fields is differenet from group by fields, GroupByMemoryMergedResult will be used.
in GroupByMemoryMergedResult, if there is no data, it will try to generate one row, when select fields have count(1), it will renturn 0

image

image

@terrymanu
Copy link
Member

What is the configuration?

@peacefulprogram
Copy link
Author

zookeeper cluster mode, and the sharding rules is in follow image
image

@terrymanu
Copy link
Member

The issue contains only images, which is not conducive to search or code copying by contributors. Could you please recreate an new issue and describe it again using text and code?

@peacefulprogram
Copy link
Author

Sure. I'll create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants