You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "menghaoranss (via GitHub)" <gi...@apache.org> on 2026/05/06 08:12:02 UTC
[PR] Refactor table identifier lookup for heterogeneous databases with LOGICAL_TABLE scope fallback [shardingsphere]
menghaoranss opened a new pull request, #38672:
URL: https://github.com/apache/shardingsphere/pull/38672
Fixes #ISSUSE_ID.
Changes proposed in this pull request:
This PR refactors table identifier matching to support heterogeneous protocol/storage database combinations while keeping existing behavior for homogeneous deployments.
### What changed
1. Added LOGICAL_TABLE to IdentifierScope.
2. Moved logical-table matching rules into IdentifierCaseRuleSet (instead of storing a separate logical rule in DatabaseIdentifierContext).
3. Kept TABLE scope aligned with storage-side identifier rules (physical table matching).
4. Added heterogeneous lookup flag in DatabaseIdentifierContext and enabled fallback initialization only when protocol type differs from storage type.
5. Updated ShardingSphereSchema table lookup flow:
- primary lookup: LOGICAL_TABLE index (protocol rule, heterogeneous only)
- fallback lookup: TABLE index (storage rule)
6. Kept physical metadata loading normalized by storage-side rules.
### Why
In heterogeneous scenarios (for example, MySQL protocol with Oracle storage), logical table names and physical table names require different identifier rules:
- logical names should follow protocol semantics
- physical names should follow storage semantics
This change provides both without requiring callers to know whether a name is logical or physical.
### Scope / compatibility
- Homogeneous protocol/storage: no extra logical fallback index is initialized.
- Heterogeneous protocol/storage: logical fallback index is initialized and used.
- No table metadata object duplication; only additional index/mapping references.
### Tests
Added/updated tests to cover:
- LOGICAL_TABLE rule wiring and heterogeneous flag behavior in DatabaseIdentifierContextFactoryTest
- schema lookup behavior with logical-first fallback in heterogeneous mode in ShardingSphereSchemaIdentifierTest
- existing infra/common targeted tests pass after changes.
---
Before committing this PR, I'm sure that I have checked the following options:
- [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [ ] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [ ] 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.
- [ ] I have added corresponding unit tests for my changes.
- [ ] I have updated the Release Notes of the current development version. For more details, see [Update Release Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
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] Refactor table identifier lookup for heterogeneous databases with LOGICAL_TABLE scope fallback [shardingsphere]
Posted by "menghaoranss (via GitHub)" <gi...@apache.org>.
menghaoranss commented on PR #38672:
URL: https://github.com/apache/shardingsphere/pull/38672#issuecomment-4386620650
Merge Verdict: Mergeable
Reviewed Scope
Latest head of PR #38672: c11cbf02373becf6796f54079e8684b39c9435bd
All 6 changed files (IdentifierScope, ShardingSphereSchema, DatabaseIdentifierContext*, and 2 related test classes)
Focused re-check on your new heterogeneous-detection fix and mixed-storage counterexample coverage
Not Reviewed Scope
No end-to-end JDBC/Proxy integration rerun in real deployment topology (review is code + unit-test level)
Need Expert Review
No (normal infra/metadata maintainer review is sufficient)
Why this is now mergeable
Root cause is now actually fixed:
Heterogeneous detection no longer depends on a single findFirst() storage type.
It now evaluates all storage types via isHeterogeneous(protocolType, getStorageDatabaseTypes(...)), which closes the mixed-storage false-negative path.
Regression-risk controls are in place:
Added mixed-storage test where first storage matches protocol but another differs.
Added order-independence test (MySQL-first vs Oracle-first).
Homogeneous disabled-path assertions are still present.
Lookup semantics remain safe:
Physical index remains first-priority, logical fallback second, so same-name shadowing behavior does not regress.
Pre-merge note
Unit tests and checkstyle for the touched module are aligned with the fix.
GitHub statuses API for the head SHA currently returns empty in this check; please confirm PR CI panel is green before merge.
--
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] Refactor table identifier lookup for heterogeneous databases with LOGICAL_TABLE scope fallback [shardingsphere]
Posted by "menghaoranss (via GitHub)" <gi...@apache.org>.
menghaoranss merged PR #38672:
URL: https://github.com/apache/shardingsphere/pull/38672
--
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