Repository navigation
fix: prepared statements read numeric and decimal as exact text under numeric strings (#498) - #501
Merged
Merged
Conversation
… numeric strings (#498) With numeric strings on at prepare, numeric and decimal result columns are bound as wide text instead of a double, so they keep every digit; the prepared reader picks its path from the binding's C type. The text is the same as a query gives for the same rows, scale and leading zero included. With numeric strings off nothing changes. Corpus scripts/issue-498-prepared now compares a query and a prepared statement over the same rows (agreed); a unit test reads 120 rows, three fetch blocks. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Fixes #498 (the last part, after #499 and #500).
With numeric strings on at prepare,
numericanddecimal(money,smallmoney) result columns were bound as a double, so a prepared statement lost digits that a query keeps.BoundDatum::reserve_column_typenow binds them as wide text in that case, anddispatch_preparedpicks the reader from the binding's C type (reserved_numeric_text). The text is the same as a query gives: every digit, the column's scale, and the leading zero.decimal(38,2)12345678901234567.89"12345678901234568""12345678901234567.89"money922337203685477.5807"922337203685477.6""922337203685477.5807"numeric(38,10)-0.5"-0.5""-0.5000000000"With numeric strings off nothing changes: the columns are still bound as a double and read as numbers.
Tests
scripts/issue-498-prepared(agreed): a query, then a prepared statement with numeric strings on and off, over the same rows (a null, values below 1, money, float). The prepared text is identical to the query's.Seen on the way, not changed here: a prepared
select top (?) …is described with no columns at prepare and returns no rows, with numeric strings on or off. It's the same no-metadata-at-prepare bug asselect 10 / ? as n.🤖 Generated with Claude Code