Repository navigation
[jdbc-v2] RowBinary writer: store the values of setBytes, the stream setters and setURL - #3414
Open
polyglotAI-bot wants to merge 1 commit into
Open
polyglotAI-bot wants to merge 1 commit into
polyglotAI-bot wants to merge 1 commit into
Conversation
…setters and setURL With beta.row_binary_for_simple_insert=true, WriterStatementImpl had empty bodies for setBytes, all overloads of setAsciiStream, setUnicodeStream, setBinaryStream, setCharacterStream and setNCharacterStream, and setURL. The value never reached RowBinaryFormatWriter, so the column got NULL, its default, or the insert failed with "An attempt to write null into not nullable column". The setters now give the value to the writer. setBytes passes the array. The InputStream setters read the bytes, and the Reader setters read the characters, up to the length when one is given. setURL passes the URL text. A negative length, a stream that ends before the length, or a read failure throws SQLException. Fixes: #3406 Fixes: #3334 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Auto-approved by the AI review gate on 5677c1a. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
1 task
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.
Summary
Closes #3406
Closes #3334 (the same defect, with a reproduction)
With
beta.row_binary_for_simple_insert=true,WriterStatementImplhad empty bodies forsetBytes, all overloads ofsetAsciiStream,setUnicodeStream,setBinaryStream,setCharacterStreamandsetNCharacterStream, andsetURL. The value never got toRowBinaryFormatWriter. AtcommitRow()the slot wasnull: aNullablecolumn gotNULL, a column with a default got the default, and other columns failed with "An attempt to write null into not nullable column".The setters now give the value to the writer:
setBytes: thebyte[].InputStreamsetters: the bytes, read before the setter returns, up tolengthwhen given. No UTF-8 decoding, so binary data is stored byte for byte.Readersetters: the characters, read before the setter returns, up tolengthwhen given.setURL:URL.toString().nullstream or URL: same assetNull.SQLException(HY000). A stream that ends beforelength, or a read failure:SQLException(07000, the state ofPreparedStatementImplfor a stream read error). The message names the parameter.The streams are read in
jdbc-v2, not withRowBinaryFormatWriter.setInputStream/setReader: those store the holder'stoString()(#3336, not in this PR).setBlob,setClob,setNClobandsetSQLXMLuse them and are still affected by #3336. The typedsetObjectoverloads (#3408) are also not in this PR.Test
WriterStatementImplTest, against ClickHouse 26.10 in a devbox:testWriterStoresValueOfBytesStreamAndUrlSetters: all 14 setters, one@DataProviderrow each. Each setter bindsNullable(String),String DEFAULT 'x'andStringcolumns, with anInt32column after them, in a batch of rows: ASCII, non-ASCII, empty,null. Thenullrow must giveNULLand'x'. Onmain, all 14 rows fail.testWriterStoresRawBytesAndReadsOnlyStreamLength: non-UTF-8 bytes throughsetBytes(intoFixedString(3)) andsetBinaryStream; a stream longer thanlengthstores onlylengthbytes or characters, and the rest of the stream is not read. Fails onmain.testWriterStreamSetterFailsForUnreadableStream: a stream shorter thanlength, a negative length, and a stream that throwsIOException, forInputStreamandReader. Checks the SQL state. Onmain, nothing is thrown.WriterStatementImplTest,PreparedStatementTestandJDBCDateTimeTestspass (160 tests). The jdbc-v2 unit tests pass (2033).Checklist
history/latest/3406.mddocs/changes_checklist.md: no new public method, no logging, config, enum or default change. The exception handling of the 14 setters is new (SQLExceptionfor an invalid length or an unreadable stream).docs/features.mdhas one new line for the writer behavior of these setters.🤖 Generated with Claude Code
Note
Medium Risk
Changes insert binding behavior on an opt-in beta path and adds new SQLException cases for stream parameters; limited to simple
INSERT ... VALUES (?)when the RowBinary writer is enabled.Overview
Fixes a bug in
WriterStatementImplwhenbeta.row_binary_for_simple_insert=true:setBytes, allInputStream/Readeroverloads, andsetURLwere no-ops, so inserts often wrote NULL, used column defaults, or failed on non-nullable columns.Those setters now forward real values to the RowBinary writer—byte-for-byte for bytes and binary/ASCII streams, text for character streams and URLs—with streams fully read at bind time. Invalid binds raise
SQLException(negative length, short stream, or I/O error).docs/features.mdandhistory/latest/3406.mddocument the behavior.WriterStatementImplTestadds integration coverage for all 14 setters, length semantics, and error SQL states.Reviewed by Cursor Bugbot for commit 5677c1a. Bugbot is set up for automated code reviews on this repo. Configure here.