You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "TherChenYang (via GitHub)" <gi...@apache.org> on 2024/06/13 10:05:25 UTC
[PR] Fix Sharding column not tracked through aliases [shardingsphere]
TherChenYang opened a new pull request, #31687:
URL: https://github.com/apache/shardingsphere/pull/31687
Fixes #31656.
Changes proposed in this pull request:
- Fix Sharding column not tracked through aliases
- When there is an alias for our sharded column, errors may occur in judging the shard condition, leading to routing all tables in the database.
- When the alias of our regular column happens to be the same as the partitioned column, it will also incorrectly judge the slice condition, resulting in an incorrect route.
``` sql
-- alias for sharding column
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account) t1 WHERE aliased_account_id = 100
-- Incorrect routing result
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account_0) t1 WHERE aliased_account_id = 100
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account_1) t1 WHERE aliased_account_id = 100
-- Correct routing result
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account_0) WHERE aliased_account_id = 100
```
``` sql
--- sharding column with alias
SELECT * FROM (SELECT amount account_id FROM t_account) t1 WHERE account_id = 100
-- Incorrect routing result
SELECT * FROM (SELECT amount account_id FROM t_account_0) t1 WHERE account_id = 100
-- Correct routing result
SELECT * FROM (SELECT amount account_id FROM t_account_0) t1 WHERE account_id = 100
SELECT * FROM (SELECT amount account_id FROM t_account_1) t1 WHERE account_id = 100
```
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] I have self-reviewed the commit code.
- [x] I have (or in comment I request) added corresponding labels for the pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Sharding column not tracked through aliases [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #31687:
URL: https://github.com/apache/shardingsphere/pull/31687
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org