Skip to content

Make unquoted schema lookup case-insensitive for PostgresSQL#38696

Merged
menghaoranss merged 1 commit into
apache:masterfrom
menghaoranss:dev-1
May 15, 2026
Merged

Make unquoted schema lookup case-insensitive for PostgresSQL#38696
menghaoranss merged 1 commit into
apache:masterfrom
menghaoranss:dev-1

Conversation

@menghaoranss
Copy link
Copy Markdown
Contributor

@menghaoranss menghaoranss commented May 15, 2026

Changes proposed in this pull request:

  • Make unquoted schema lookup case-insensitive for PostgresSQL

PR Title
Refine PostgreSQL/openGauss schema identifier rules: case-insensitive unquoted lookup with exact quoted match

PR Description

Summary

This PR adjusts schema identifier matching for PostgreSQL and openGauss to support mixed-case stored schema names while preserving quoted-identifier semantics.

Changes

  • Updated PostgreSQL identifier case rule provider:
    • Override IdentifierScope.SCHEMA with newInsensitiveRuleSet().getRule(IdentifierScope.SCHEMA).
    • Keep other scopes on the existing lower-case rule set.
  • Updated openGauss identifier case rule provider with the same schema-scope override.
  • Updated related unit tests to reflect the new schema behavior.

Behavior After Change

For schema identifiers in PostgreSQL/openGauss:

  • Unquoted lookup is case-insensitive (LookupMode.NORMALIZED).
  • Quoted lookup remains exact (LookupMode.EXACT behavior for quoted identifiers).

Other identifier scopes (table/column/view/etc.) keep their previous behavior.

Why

Previously, PostgreSQL/openGauss schema rules filtered unquoted candidates by lower-case stored names.
That could fail when schema metadata was stored in upper-case or mixed-case forms.
This change ensures unquoted schema lookup can still resolve those names, while quoted lookup remains strict.

Verification

Executed:

  • ./mvnw -pl database/connector/dialect/postgresql,database/connector/dialect/opengauss -am -DskipITs -Dspotless.skip=true -Dtest=PostgreSQLIdentifierCaseRuleProviderTest,OpenGaussIdentifierCaseRuleProviderTest test -Dsurefire.failIfNoSpecifiedTests=false
  • ./mvnw -pl infra/common -DskipITs -Dspotless.skip=true -Dtest=DatabaseIdentifierContextFactoryTest test -Dsurefire.failIfNoSpecifiedTests=false

All passed.


Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct 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

@menghaoranss
Copy link
Copy Markdown
Contributor Author

Core conclusion: this PR is safe to merge.

1) Decision

  • Merge Verdict: Mergeable
  • Reviewed Scope
    • database/connector/dialect/postgresql/.../PostgreSQLIdentifierCaseRuleProvider.java
    • database/connector/dialect/opengauss/.../OpenGaussIdentifierCaseRuleProvider.java
    • Both provider unit tests
    • Schema-lookup parameterized cases in infra/common/.../DatabaseIdentifierContextFactoryTest.java
  • Not Reviewed Scope
    • No full local rebuild/e2e run by me; review is based on latest diff, CI, key runtime path, and test semantics
  • Need Expert Review
    • No

2) Root-Cause and Fix Mapping

  • Root cause is valid: PostgreSQL/openGauss schema lookup previously depended on lower-case matching and could miss mixed/upper stored schema names for unquoted identifiers.
  • Fix maps correctly: IdentifierScope.SCHEMA is overridden to insensitive matching, while other scopes keep lower-case behavior.
  • Semantics align with official docs:
    • PostgreSQL: unquoted identifiers are folded to lower case; quoted identifiers are case-sensitive.
      PostgreSQL docs
    • openGauss docs (quote_ident) describe quoting when identifier would be case-folded, consistent with the same model.
      openGauss docs

3) Risk Scan (including adversarial pass)

  • Cross-dialect/adjacent-feature regression: change is limited to PostgreSQL/openGauss providers; MySQL/Oracle paths are untouched.
  • Config-disabled/flag path: METADATA_IDENTIFIER_CASE_SENSITIVITY override in IdentifierCaseRuleResolver remains unchanged and still has higher priority than provider defaults.
  • Partial symptom coverage risk: tests now include schema unquoted/quoted positive/negative checks and mixed stored-case schema cases in context factory coverage.

4) Validation Evidence

  • CI for head f7e691d...: core checks are green (CI, CheckStyle, Spotless, License all success). Some E2E jobs are skipped by matrix strategy.
  • Scope is tight: 5 files, 1 commit, no unrelated changes observed.
  • Code-of-conduct alignment:
    • Build/check expectations: CODE_OF_CONDUCT.md lines 18-20
    • Test behavior expectations: lines 96-99

5) Commands Run (exit code)

  • curl -sL https://api.github.com/repos/apache/shardingsphere/pulls/38696 (0)
  • curl -sL https://api.github.com/repos/apache/shardingsphere/pulls/38696/files?per_page=100 (0)
  • curl -sL https://api.github.com/repos/apache/shardingsphere/pulls/38696/commits?per_page=100 (0)
  • curl -sL https://api.github.com/repos/apache/shardingsphere/commits/f7e691dbe0a0c0cf86e3de561a1b09cba1a9bb02/check-runs | jq -r ... (0)

Short summary: this is a minimal, semantics-consistent fix with adequate risk coverage and passing CI evidence; merge is recommended.

@menghaoranss menghaoranss merged commit 579de83 into apache:master May 15, 2026
31 checks passed
@menghaoranss menghaoranss deleted the dev-1 branch May 15, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants