Skip to content

fix: prepared statements read numeric and decimal as exact text under numeric strings (#498) - #501

Merged
TimelordUK merged 1 commit into
masterfrom
fix/prepared-numeric-string
Oct 24, 2026
Merged

TimelordUK merged 1 commit into
masterfrom
fix/prepared-numeric-string

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

Fixes #498 (the last part, after #499 and #500).

With numeric strings on at prepare, numeric and decimal (money, smallmoney) result columns were bound as a double, so a prepared statement lost digits that a query keeps. BoundDatum::reserve_column_type now binds them as wide text in that case, and dispatch_prepared picks 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.

prepared, numeric strings on before after
decimal(38,2) 12345678901234567.89 "12345678901234568" "12345678901234567.89"
money 922337203685477.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

  • Corpus 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.
  • Unit test: 120 prepared rows (three fetch blocks of 50), so each row is read from its own place in the bound array.
  • Full suite on Windows / ODBC 18: 1195 passing, 1 pending.

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 as select 10 / ? as n.

🤖 Generated with Claude Code

… 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]>
@TimelordUK
TimelordUK merged commit a9c1d95 into master Oct 24, 2026
11 checks passed
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.

numeric_string: float, real, decimal and money come back as %f strings (1e-10 becomes "0.000000")

1 participant