Repository navigation
Conversation
Reuse setDate conversion for Date and Date32 when the bound parameters follow the writable table order. Keep existing binding for unresolved and reordered column lists and for generated columns in the bound range. Refs ClickHouse#3386
3 tasks done
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
With
beta.row_binary_for_simple_insert=true, binding ajava.sql.DateviaPreparedStatement.setObjectfails when the writer adds a row to the batch. Use the existingsetDatecalendar conversion forDateandDate32when the placeholders are known to follow the table's writable column order.The beta writer sends RowBinary without a target column list and skips generated columns. Unresolved or reordered lists and generated fields within the bound positions retain their existing date-binding behavior.
Closes #3386.
Verification
addBatch()failure on75063012. The JDBC regression now reads the expectedDate, pre-epochDate32, nullable date and following integer from ClickHouse.JDBCDateTimeTests,WriterStatementImplTestandPreparedStatementTeston ClickHouse 26.12.1.263 and Corretto JDK 17.0.21.1, both using UTC.clickhouse-jdbc-allbuild passed. The packaged driver stored the expected date and following integer. Its reordered-list and generated-column probes produced the same results as the base driver.ClickHouseStringValueTest#testValue. The same assertion fails when running the unchangedclickhouse-datamodule on its own.Checklist
AI assistance
OpenAI Codex prepared the patch and ran the listed checks.
Note
Medium Risk
Changes prepared-insert parameter encoding for a beta RowBinary path and ties it to SQL parser metadata; wrong gating could mis-bind dates or mask unsafe column orders.
Overview
Fixes jdbc-v2 RowBinary simple inserts (
beta.row_binary_for_simple_insert) soPreparedStatement.setObject(..., java.sql.Date)works when placeholders align with the table's writable column order, using the same conversion assetDate(...)for Date and Date32.WriterStatementImpl now tracks whether binding order is trusted (
usesTableColumnOrder): resolved insert columns, table-order inserts without generated/default columns in the bound prefix, and no parser-flagged unresolved column list. Only then doessetObjectspecial-casejava.sql.Date; reordered column lists and inserts before skipped materialized columns keep the prior failure behavior.The JavaCC parser records unresolved insert column lists via
ParsedPreparedStatement.hasUnresolvedInsertColumns(). Docs and a changelog note the RowBinary date behavior; integration tests cover in-order success and rejected reorder/generated-column cases across parser backends.Reviewed by Cursor Bugbot for commit 23165d4. Bugbot is set up for automated code reviews on this repo. Configure here.