Commit d026ec7
committed
Consolidate Issue #161 fix behind two single-purpose helpers
The previous fix inlined the SQL_VARYING prefix write
(`*(unsigned short*)buf = len;` + data at `buf + 2`) into 18
`conv<Numeric|Date|Time>ToString[W]` helpers and repeated the
SQL_C_WCHAR → byte-variant reroute at 8 switch sites in
`getAdressFunction`, with a peek-only `HeadSqlVar::isSqlVarying()`
getter to let the ODBC layer inspect the prepared sqltype.
That shape is hard to maintain (any future `convDecfloatToString`
has to remember to copy the same branch) and leaks Firebird
buffer-layout knowledge into the ODBC conversion layer.
This commit collapses the repetition behind two named primitives:
* `HeadSqlVar::writeStringData(src, len)` — new inline method on
the IscDbc interface, beside `setSqlLen`/`setSqlData`. It writes
into the sqlvar's pre-allocated buffer using the correct layout
for the prepared type (`[uint16 len][data]` for SQL_VARYING,
bare bytes + effective sqllen for SQL_TEXT) and does not mutate
the VARYING metadata. Replaces the `isSqlVarying()` getter —
behavior, not a peek.
* `writeConvertedString(pointer, indicatorTo, to, src, len)` — new
file-scope helper in OdbcConvert.cpp. Single write-back path for
every numeric/date/time → string converter: Firebird-side targets
go through `writeStringData`, app-owned targets get a bare memcpy
+ indicator update. Each `conv*ToString` helper now produces a
local ASCII buffer and calls this helper instead of touching
`*(unsigned short*)pointer` or `setSqlLen` directly.
* `chooseNumericToStringConv(to, byteFn, wideFn)` — tiny inline that
replaces the 8 identical `if (to->isIndicatorSqlDa) return byte;
else return wide;` blocks in `getAdressFunction`. The rationale
comment lives once, at the helper.
Also rewrites the `Sqlda::getPrecision` comment to explain that the
`orgVarSqlProperties` read for INPUT parameters is a symmetry with
the existing `getColumnDisplaySize` pattern (INPUT precision is
immutable from prepare time), not an Issue-161-specific workaround.
Code behavior unchanged.
Net: 18 + 8 scattered sites replaced by 2 helpers and 1 method;
ODBC layer no longer writes uint16 length prefixes or reads
`sqltype == SQL_VARYING`.
Verified against Firebird 5.0.3 on Windows x64, across all three
charset configs (UTF8+UTF8, ISO8859_1+ISO8859_1, ISO8859_1+UTF8):
125 passing tests / 0 failing, including
`Issue161_SLongToVarcharViaStoredProcedure`,
`Issue161_SLongToVarcharViaDml`, `NumericAsCharParam` and the rest
of `ParamConversionsTest` / `WCharTest`.1 parent 3d3b7a2 commit d026ec7
4 files changed
Lines changed: 150 additions & 220 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
528 | 527 | | |
529 | 528 | | |
530 | 529 | | |
531 | 530 | | |
| 531 | + | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
106 | 126 | | |
107 | 127 | | |
108 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
772 | 770 | | |
773 | 771 | | |
774 | 772 | | |
| |||
0 commit comments