zxs1633079383 opened a new pull request, #37216:
URL: https://github.com/apache/shardingsphere/pull/37216
Fixes #36978
Changes proposed in this pull request
This PR fixes the incorrect handling of PostgreSQL custom types (UDT, enum)
and VARBIT/BIT VARYING in ShardingSphere-Proxy, especially under the extended
query protocol (Parse → Bind → Describe → Execute).
The main issue was that all PostgreSQL Types.OTHER were incorrectly mapped
to JSON, causing protocol inconsistencies and incorrect parameter/column
parsing.
1. Type System Improvements
Added explicit support for PostgreSQL VARBIT and VARBIT_ARRAY with a
dedicated value parser.
Introduced UDT_GENERIC to represent PostgreSQL user-defined types (enum,
domain, composite).
Added detection logic based on both JDBC type and actual columnTypeName.
Removed the incorrect fallback mapping: Types.OTHER → JSON.
2. Parse Phase Enhancement
Parse phase now propagates both parameterTypes and parameterTypeNames into
PostgreSQLServerPreparedStatement.
Ensures downstream Bind/Describe phases can resolve correct PostgreSQL types
instead of JSON.
3. Describe Phase Fixes
Insert statements now resolve column types (dataType, typeName) from
ShardingSphere metadata.
Automatically assigns accurate PostgreSQL column types to each parameter
(including UDT + VARBIT).
Saves resolved typeName into the prepared statement for Bind phase use.
4. Bind Phase Corrections
Construct proper PGobject when binding UDT or JSONB parameters using the
resolved typeName.
Prevent JSON fallback for VARBIT and UDT parameters.
Ensures PostgreSQL receives correct parameter type during Bind.
5. Metadata Enhancements
Added typeName to ColumnMetaData and ShardingSphereColumn.
PostgreSQLDataTypeOption updated to:
Include VARBIT / BIT VARYING in extra types.
Load all PostgreSQL UDTs dynamically via pg_type (enum, composite, domain).
6. End-to-End Validation
Verified on PostgreSQL 17.5 with real application workloads:
INSERT: VARBIT and custom UDT work correctly.
SELECT: raw VARBIT bitstring + UDT enum returned correctly.
UPDATE: bitwise OR on VARBIT executed successfully.
No JSON fallback or protocol errors.
This fully resolves issue #36978.
Before committing this PR, I'm sure that I have checked the following
options:
### Checklist
- [x] I have self-reviewed the commit code.
- [x] I have added (or requested) the correct labels for this PR.
- [x] I have passed the Maven check locally:
`./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`
- [ ] I have updated the relevant documentation.
- [x] I have added unit tests for my changes.
- [x] I have updated the Release Notes for the current development version.
(https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
<img width="2048" height="1084" alt="12951764386988_ pic"
src="https://github.com/user-attachments/assets/e35e5a2e-039b-4508-bfa9-3ba5dda5700b"
/>
<img width="2048" height="873" alt="12961764386994_ pic"
src="https://github.com/user-attachments/assets/09929792-a98f-4450-8e2c-2ad648c4dbba"
/>
<img width="1711" height="1155" alt="12971764386999_ pic"
src="https://github.com/user-attachments/assets/43c60081-a053-454e-a793-0a7c1156689b"
/>
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]