Implement write methods for PostgreSQLUnspecifiedBinaryProtocolValue#38570
Open
daguimu wants to merge 2 commits into
Open
Implement write methods for PostgreSQLUnspecifiedBinaryProtocolValue#38570daguimu wants to merge 2 commits into
daguimu wants to merge 2 commits into
Conversation
Author
|
Hi, I have just addressed the Spotless violations in a follow-up commit; CI should now pass. Would appreciate a review when someone has time. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostgreSQLUnspecifiedBinaryProtocolValue.write()andgetColumnLength()throwUnsupportedSQLOperationException, preventing unspecified-type values from being written through the PostgreSQL binary protocol path.Root Cause
The
write()andgetColumnLength()methods were left as stubs throwingUnsupportedSQLOperationExceptionwhen the class was initially created. This is one of the items tracked in #35830.Fix
Implemented both methods following the same pattern as
PostgreSQLStringBinaryProtocolValue:getColumnLength(): returns the byte length ofvalue.toString()using the payload's charset, correctly handling multi-byte characterswrite(): writes the string representation viapayload.writeStringEOF(value.toString()), which works for both plain String values andPostgreSQLTypeUnspecifiedSQLParameterinstances (which delegate to their inner string viatoString())Removed the unused
UnsupportedSQLOperationExceptionimport.Tests Added
getColumnLengthreturns correct byte lengthassertGetColumnLength—"val"→ 3,PostgreSQLTypeUnspecifiedSQLParameter("test")→ 4getColumnLengthhandles multi-byte charactersassertGetColumnLengthWithMultiByteCharset—"中文"→ 6 (UTF-8)writeoutputs string bytes to payloadassertWrite— verifies"val"bytes written to ByteBufwriteworks withPostgreSQLTypeUnspecifiedSQLParameterassertWriteWithTypeUnspecifiedParameter— verifies"test"bytes writtenImpact
Only affects the unspecified binary protocol value type in the PostgreSQL protocol module. Enables binary write support for unspecified-type columns. No changes to other protocol value implementations.
Partial fix for #35830