Commit 519c24b
Shiwani Gupta
mssql-odbc: declare and bound data-at-execution parameters from ParameterType
SQLBindParameter's ParameterType and ColumnSize were ignored for
data-at-execution parameters: every value streamed as a `max` type
whatever the application declared, and no length bound was enforced.
Declaration follows ParameterType. `dae_plan` decides stream-vs-buffer
from the SQL type's PLP-ability, mirroring msodbcsql's IsPartialLenType
(sqlcprot.h:1421), which keys on the SQL type alone rather than on
ColumnSize. A fixed-width target is now collected and converted whole
through the materializing path instead of being forced into a `max`
stream it cannot represent.
ColumnSize bounds the value. `dae_streamed_declaration` narrows the
@params declaration and `dae_length_limit` enforces the accumulated
total in SQLPutData, applied before the streamed/buffered split and
against the application buffer -- where msodbcsql runs
ValidatePutDataLength (sqlccmd.cpp:4571), so 22001 lands on the call
that overflows rather than at close. Trailing pad units are trimmed
rather than rejected, including one split across two calls, and trimmed
padding does not consume the declaration's budget. A narrow buffer is
measured in UTF-16 units, the unit the materialized path uses, so the
two paths agree on what fits. The declaration is only narrowed when that
bound can be enforced: a streamed parameter never reaches a close-time
conversion, so promising a length nothing checks would leave the
overflow to the server.
Transcoding is streamed, not deferred. `DaeTranscode` converts each
chunk on the way out, carrying a trailing partial character into the
next call -- the shape of msodbcsql's ConvertLongData (sqlccnvt.cpp:841)
with its cbTruncatedCharsInConvBuf carry and end-of-value flush
(sqlccmd.cpp:5999-6001). Narrow encoding reuses encode_narrow, so the
streamed and materialized paths agree on the wire bytes.
A mixed sequence collects only what it must. Parameters are offered in
bind order, as msodbcsql offers them, and the RPC opens as soon as no
parameter still to be visited needs collecting -- so a PLP-capable value
bound after a fixed-width one streams rather than being held whole.
text/ntext/image keep their `max` substitution, tracked under AB#47592.
AB#475901 parent ce029d8 commit 519c24b
14 files changed
Lines changed: 2926 additions & 628 deletions
File tree
- mssql-odbc
- docs
- src
- api
- conversion
- handles
- tests/e2e/tests
- mssql-tds/src/message/parameters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 96 | + | |
103 | 97 | | |
104 | 98 | | |
105 | 99 | | |
| |||
0 commit comments