Skip to content

Implement write methods for PostgreSQLUnspecifiedBinaryProtocolValue#38570

Open
daguimu wants to merge 2 commits into
apache:masterfrom
daguimu:fix/postgresql-unspecified-binary-write-35830
Open

Implement write methods for PostgreSQLUnspecifiedBinaryProtocolValue#38570
daguimu wants to merge 2 commits into
apache:masterfrom
daguimu:fix/postgresql-unspecified-binary-write-35830

Conversation

@daguimu
Copy link
Copy Markdown

@daguimu daguimu commented Mar 27, 2026

Problem

PostgreSQLUnspecifiedBinaryProtocolValue.write() and getColumnLength() throw UnsupportedSQLOperationException, preventing unspecified-type values from being written through the PostgreSQL binary protocol path.

Root Cause

The write() and getColumnLength() methods were left as stubs throwing UnsupportedSQLOperationException when 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 of value.toString() using the payload's charset, correctly handling multi-byte characters
  • write(): writes the string representation via payload.writeStringEOF(value.toString()), which works for both plain String values and PostgreSQLTypeUnspecifiedSQLParameter instances (which delegate to their inner string via toString())

Removed the unused UnsupportedSQLOperationException import.

Tests Added

Change Point Test
getColumnLength returns correct byte length assertGetColumnLength"val" → 3, PostgreSQLTypeUnspecifiedSQLParameter("test") → 4
getColumnLength handles multi-byte characters assertGetColumnLengthWithMultiByteCharset"中文" → 6 (UTF-8)
write outputs string bytes to payload assertWrite — verifies "val" bytes written to ByteBuf
write works with PostgreSQLTypeUnspecifiedSQLParameter assertWriteWithTypeUnspecifiedParameter — verifies "test" bytes written

Impact

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

@daguimu
Copy link
Copy Markdown
Author

daguimu commented Apr 23, 2026

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant