You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "WangYjing (via GitHub)" <gi...@apache.org> on 2025/12/01 03:39:18 UTC
[PR] Issue with Boolean field return in PG database when accessed via proxy [shardingsphere]
WangYjing opened a new pull request, #37239:
URL: https://github.com/apache/shardingsphere/pull/37239
Fixes #37184.
Changes proposed in this pull request:
-
This fix ensures that ShardingSphere Proxy returns Boolean values (such as 't') in their native PostgreSQL format when processing PostgreSQL Boolean columns,
allowing the PostgreSQL JDBC driver to correctly parse them as true.
This eliminates the inconsistency in format and prevents business logic errors caused by incorrect Boolean parsing.
---
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] Issue with Boolean field return in PG database when accessed via proxy [shardingsphere]
Posted by "WangYjing (via GitHub)" <gi...@apache.org>.
WangYjing commented on PR #37239:
URL: https://github.com/apache/shardingsphere/pull/37239#issuecomment-3600294710
@terrymanu Could you please help review this PR?
--
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] Issue with Boolean field return in PG database when accessed via proxy [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu merged PR #37239:
URL: https://github.com/apache/shardingsphere/pull/37239
--
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] Issue with Boolean field return in PG database when accessed via proxy [shardingsphere]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #37239:
URL: https://github.com/apache/shardingsphere/pull/37239#discussion_r2581468334
##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacket.java:
##########
@@ -71,6 +71,10 @@ private void writeTextValue(final PostgreSQLPacketPayload payload, final Object
payload.writeBytes((byte[]) each);
} else if (each instanceof SQLXML) {
writeSQLXMLData(payload, each);
+ } else if (each instanceof Boolean) {
+ byte[] columnData = ((Boolean) each ? "t" : "f").getBytes(payload.getCharset());
+ payload.writeInt4(columnData.length);
+ payload.writeBytes(columnData);
Review Comment:
The Boolean to PostgreSQL text format conversion logic is duplicated. The codebase already has `PostgreSQLTextBoolUtils.getTextValue()` which performs the same conversion (Boolean to "t"/"f"). Consider refactoring to use:
```java
} else if (each instanceof Boolean) {
byte[] columnData = PostgreSQLTextBoolUtils.getTextValue(each).getBytes(payload.getCharset());
payload.writeInt4(columnData.length);
payload.writeBytes(columnData);
```
This would ensure consistency with the conversion logic used in `Portal.java` (line 201) and reduce code duplication.
##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacket.java:
##########
@@ -71,6 +71,10 @@ private void writeTextValue(final PostgreSQLPacketPayload payload, final Object
payload.writeBytes((byte[]) each);
} else if (each instanceof SQLXML) {
writeSQLXMLData(payload, each);
+ } else if (each instanceof Boolean) {
+ byte[] columnData = ((Boolean) each ? "t" : "f").getBytes(payload.getCharset());
+ payload.writeInt4(columnData.length);
+ payload.writeBytes(columnData);
Review Comment:
The new Boolean handling logic should have corresponding test coverage. Consider adding tests for both `true` and `false` Boolean values to ensure they are correctly serialized as 't' and 'f' respectively. The existing test file `PostgreSQLDataRowPacketTest.java` has tests for other data types (null, byte[], SQLXML, String), and should include a test for Boolean values as well.
--
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