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/04/09 03:41:08 UTC
[PR] Fix null-safe identifier matching for quoted normalized lookups [shardingsphere]
menghaoranss opened a new pull request, #38602:
URL: https://github.com/apache/shardingsphere/pull/38602
Changes proposed in this pull request:
This PR fixes a regression in StandardIdentifierCaseRule.matches(...) introduced while aligning quoted normalized lookup behavior.
The previous change correctly enabled quoted NORMALIZED matching for cases like MySQL with lower_case_table_names=1/2, but it accidentally removed the existing null guard in matches(...). As a result, StandardIdentifierCaseRuleTest could throw NullPointerException when either storedName or actualIdentifier was null.
- Root Cause
StandardIdentifierCaseRule.matches(...) now supports two quoted paths:
LookupMode.EXACT: compare stored and actual identifiers directly
LookupMode.NORMALIZED: compare normalized identifiers
During that refactor, the original null handling was dropped.
For unquoted matching, the method still evaluates:
unquotedStoredNamePredicate.test(storedName)
So when storedName or actualIdentifier is null, the predicate/normalizer path can fail before any equality check.
- Fix
Restore the null-safe guard at the start of matches(...):
if either storedName or actualIdentifier is null
return Objects.equals(storedName, actualIdentifier)
This preserves the quoted normalized matching fix and restores the original null-safe behavior.
- Tests
Updated StandardIdentifierCaseRuleTest to cover:
quoted normalized match
quoted null names
quoted null actual identifier
existing unquoted null scenarios
---
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] Fix null-safe identifier matching for quoted normalized lookups [shardingsphere]
Posted by "menghaoranss (via GitHub)" <gi...@apache.org>.
menghaoranss merged PR #38602:
URL: https://github.com/apache/shardingsphere/pull/38602
--
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 null-safe identifier matching for quoted normalized lookups [shardingsphere]
Posted by "menghaoranss (via GitHub)" <gi...@apache.org>.
menghaoranss commented on PR #38602:
URL: https://github.com/apache/shardingsphere/pull/38602#issuecomment-4211373293
```
Merge Verdict: Mergeable
Reviewed Scope
StandardIdentifierCaseRule.java
IdentifierCaseRuleSetsTest.java
StandardIdentifierCaseRuleTest.java
MySQLIdentifierCaseRuleProviderTest.java
IdentifierIndexTest.java
DatabaseIdentifierContextFactoryTest.java
Not Reviewed Scope
I did not run a full Proxy/JDBC end-to-end runtime reproduction.
I did not separately inspect GitHub PR comments or CI UI state.
Need Expert Review
No
Basis
The PR fixes the actual root cause in the shared matching path instead of adding fallback-only handling.
The previous inconsistency was:
MySQL insensitive rules declared quoted lookup as NORMALIZED
but StandardIdentifierCaseRule.matches(...) still treated all quoted identifiers as exact matches
The latest implementation now respects quotedLookupMode:
quoted EXACT remains exact
quoted NORMALIZED now compares normalized names
The original symptom path is no longer only partially covered by tests.
DatabaseIdentifierContextFactoryTest.java (line 161) now validates the metadata assembly path through:
DatabaseIdentifierContextFactory.create(...)
MySQL lower_case_table_names=1
ShardingSphereSchema.refreshIdentifierContext(...)
quoted table lookup with `T_MASK`
Shared-path regression risk was rechecked outside the target case:
generic insensitive quoted lookup still stays EXACT
Oracle still uses newUpperCaseRuleSet(), so quoted exact behavior is unchanged
Disabled-path behavior was also validated:
lower_case_table_names=0 still does not enable the MySQL insensitive rule
```
--
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