-
Notifications
You must be signed in to change notification settings - Fork 6.9k
fix(pg): complete PostgreSQL custom type & VARBIT support with full test coverage (includes #37216) #37259
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
base: master
Are you sure you want to change the base?
fix(pg): complete PostgreSQL custom type & VARBIT support with full test coverage (includes #37216) #37259
Conversation
… 2. 其他数据库的MetaDataLoader ColumnMetaData 占位. 3. ColumnMetaData 和ShardingSphereColumn 新增type_name 字段. 用以Pg 识别自定义Type
… 2. 其他数据库的MetaDataLoader ColumnMetaData 占位. 3. ColumnMetaData 和ShardingSphereColumn 新增type_name 字段. 用以Pg 识别自定义Type
…语句 支持识别typeName. 4. ParseExec 阶段 支持TypeName 读取. final: 稳定版本. 自定义UDT 类型 update,insert ,select ,delete 本地项目无问题.
…t-wide UDT loading Enhances PostgreSQL type consumption by adding typeName support across metadata, loaders, and prepared statements. Introduces loadUDTTypes in dialects and updates PG-specific bindings, parsing, describing, and column swapping logic.
…-tests' into fix/postgresql-custom-types-with-tests
2. Test (各个测试补齐shardingsphere的TypeName 字段值) - ShardingSphereColumnMetadata typeName 补齐内容. - MetaDataLoader 补齐typeName - PostgreDataLoader 等补齐typeName
…Column tests - Added parameterTypeNames handling in PostgreSQLServerPreparedStatement - Updated impacted test cases for prepared statement parameters - Enhanced ShardingSphereColumn related tests to align with new logic
…Column tests - Added parameterTypeNames handling in PostgreSQLServerPreparedStatement - Updated impacted test cases for prepared statement parameters - Enhanced ShardingSphereColumn related tests to align with new logic
…iance Includes UDT/VARBIT fixes, metadata/binder updates, complete test coverage, Spotless formatting, and full CI pass (-Pcheck profile).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive PostgreSQL custom type and VARBIT support by introducing a typeName field throughout the metadata chain (from ColumnMetaData to ShardingSphereColumn). The implementation enables proper handling of PostgreSQL user-defined types, enums, domains, and VARBIT in the extended protocol (Parse → Describe → Bind → Execute).
Key Changes:
- Added
typeNameparameter toShardingSphereColumnandColumnMetaDataconstructors - Enhanced PostgreSQL extended protocol to resolve and propagate type names
- Added VARBIT and JSONB value parsers for PostgreSQL
- Updated all metadata loaders across dialects to include type names
- Comprehensive test updates across ~60+ test files
Reviewed changes
Copilot reviewed 94 out of 94 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
infra/common/.../ShardingSphereColumn.java |
Added typeName field to core column model |
database/connector/core/.../ColumnMetaData.java |
Added typeName field to metadata model |
database/protocol/postgresql/.../PostgreSQLColumnType.java |
Enhanced type detection for VARBIT, JSON, JSONB |
database/protocol/postgresql/.../PostgreSQLVarBitValueParser.java |
New value parser for VARBIT type |
proxy/frontend/postgresql/.../PostgreSQLComDescribeExecutor.java |
Type resolution during Describe phase |
proxy/frontend/postgresql/.../PostgreSQLComBindExecutor.java |
PGobject construction with typeName |
database/connector/postgresql/.../PostgreSQLMetaDataLoader.java |
Propagates typeName from database |
| Test files (60+ files) | Updated constructor calls with typeName parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
...c/test/java/org/apache/shardingsphere/test/it/rewriter/engine/scenario/MixSQLRewriterIT.java
Outdated
Show resolved
Hide resolved
...ava/org/apache/shardingsphere/sqlfederation/compiler/compiler/it/SQLStatementCompilerIT.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
Outdated
Show resolved
Hide resolved
...t/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
Outdated
Show resolved
Hide resolved
...e/shardingsphere/infra/binder/engine/segment/dml/from/type/SimpleTableSegmentBinderTest.java
Outdated
Show resolved
Hide resolved
...oxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsProxyBackendHandlerTest.java
Outdated
Show resolved
Hide resolved
...here/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatement.java
Show resolved
Hide resolved
...here/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatement.java
Show resolved
Hide resolved
|
Hi @yx9o I’ve updated the PR and fixed all Checkstyle violations. Thanks a lot for your time and support. |
terrymanu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Scope creep: The PR mixes PostgreSQL UDT support with many unrelated changes (e.g., checkstyle config reformatting, sample YAML). Please split and keep only the minimal UDT-related changes.
- Thread-safety / correctness: PostgreSQLColumnType now holds a mutable typeName on enum instances via withTypeName(). Enums are global singletons; mutating them is not thread-safe and can cause cross-row type leakage. Please remove mutable state and use a stateless
mapping approach. - Types.OTHER / JSONB regressions: Defaulting Types.OTHER to UDT_GENERIC and routing JSONB through the UDT parser may break existing behavior. Revisit this mapping and add tests to cover JSONB and non-UDT Types.OTHER.
- UDT discovery: UDT scan is hardcoded to public schema and adds extra catalog queries without cache/option. Clarify scope/configuration and add tests to validate UDT handling (text/binary binds, routing, protocol output).
- Tests missing: No unit/IT coverage for UDT, JSONB, or the new Types.OTHER handling. Please add targeted tests and a minimal reproducible scenario.
Please address the above and resubmit.
|
Hi @terrymanu
Just to confirm my understanding:
The previous withTypeName() usage has already been fully removed.
Current behavior: UDTs remain Types.OTHER in metadata JSON → "json" JSONB → "jsonb" JSON / JSONB bypass UDT logic Other Types.OTHER use normal fallback No UDT_GENERIC mapping in the current PR Bind phase only uses typeName to construct PGobject I will add focused tests to validate JSON / JSONB / UDT / non-UDT behavior.
I will improve UDT loading with: an enable/disable option optional caching , and more in the future. and add tests for protocol behavior.
I will add the missing tests for: UDT bind/describe/execute JSON / JSONB non-UDT Types.OTHER minimal reproducible scenarios Thanks again for your time and guidance. |
Fixes #36978.
This PR is the complete version of the PostgreSQL custom type / VARBIT fix.
It contains:
All functional changes from PR Fix/postgresql custom types PostgreSQL Custom Types Parsing Issue in ShardingSphere-Proxy #37216
(PostgreSQL extended protocol fixes, typeName propagation,
UDT/enum/domain handling, VARBIT support, JSONB consistency, etc.)
Full updates to unit tests and E2E tests
to ensure that the entire build passes CI, including:
All checks pass locally:
./mvnw spotless:apply -Pcheck./mvnw clean install -B -T1C -PcheckChanges proposed in this pull request:
Before committing this PR, I'm sure that I have checked the following options:
./mvnw spotless:apply -Pcheck./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.This PR aims to provide a stable, fully tested version of the PostgreSQL custom
type implementation, and I am happy to address any additional comments.