GH-50560: [C++][FlightRPC][ODBC] Fix SQLDescribeCol column_size/decimal_digits width - #50562
Conversation
|
|
I think we reserve this for things that would be a release blocker, FWIW. CC @justing-bq for review |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect SQLDescribeCol output widths in the Flight SQL ODBC driver so callers receive fully-initialized column_size for numeric/decimal types (and correct buffer-size arguments for decimal_digits), addressing GH-50560 and preventing nondeterministic garbage in upper bytes.
Changes:
- In
SQLDescribeCol, readsSQL_DESC_PRECISIONinto aSQLSMALLINTand widens intoSQLULENto avoid short writes intocolumn_size. - Corrects
decimal_digitsGetFieldbuffer sizes tosizeof(SQLSMALLINT)for scale / datetime precision paths. - Adds a new gtest file to validate
column_sizeis fully overwritten (and wires it into the ODBC test CMake target).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cpp/src/arrow/flight/sql/odbc/tests/describe_col_test.cc | Adds regression tests intended to catch short writes into SQLULEN column_size and validate decimal_digits. |
| cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt | Includes the new describe_col_test.cc in the ODBC test sources. |
| cpp/src/arrow/flight/sql/odbc/odbc_api.cc | Fixes write-width mismatch for numeric column_size and corrects buffer-size arguments for decimal_digits GetField calls. |
5b1944f to
1691e5c
Compare
|
@lidavidm Dropped the "Critical Fix" wording from the description |
|
@justing-bq can I get a review here please? |
1691e5c to
f2e0af2
Compare
alinaliBQ
left a comment
There was a problem hiding this comment.
nit - for the PR description, could you update to reflect that only remote tests are added?
|
@lidavidm could you help to approve the C++ Extra workflows? Hi @vikrantpuppala I work with @justing-bq and the PR overall LGTM. Just pending the CI checks. |
…/decimal_digits width SQLDescribeCol read SQL_DESC_PRECISION (a 2-byte SQLSMALLINT) directly into the caller's 8-byte SQLULEN* column_size output for numeric/decimal columns. The GetAttribute template writes exactly sizeof(T) bytes and ignores the claimed buffer_length, so only the low 2 bytes were written and the upper 6 bytes were left uninitialized garbage. Read the precision into a local SQLSMALLINT and widen-assign it into *column_size_ptr so all 8 bytes are written. Also fix the two decimal_digits sites (SQL_DESC_SCALE and datetime SQL_DESC_PRECISION) to pass sizeof(SQLSMALLINT) -- the true width of the SQLSMALLINT* decimal_digits output -- instead of sizeof(SQLULEN). Add describe_col_test.cc, which pre-fills column_size with an all-ones sentinel and asserts SQLDescribeCol fully overwrites it for DECIMAL and TIMESTAMP columns. Introduced by apacheGH-47724 (apache#48052). Signed-off-by: Vikrant Puppala <vikrantpuppala@gmail.com>
f2e0af2 to
0cf6b9c
Compare
|
@alinaliBQ updated the PR desc - thanks for looking into the PR. |
|
@lidavidm can we get this merged? |
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 4049d6e. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 8 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
SQLDescribeColreturned uninitialized garbage in the upper bytes of itscolumn_size(ColumnSizePtr) output for numeric / decimal / integer / floatcolumns.
The numeric path read
SQL_DESC_PRECISION(2 bytes) directly into the caller'sSQLULEN* column_size_ptr(8 bytes). Also, two sites passedsizeof(SQLULEN)as the buffer size even though
decimal_digits_ptris aSQLSMALLINT*.Introduced by GH-47724 (#48052).
What changes are included in this PR?
column_sizepath: readSQL_DESC_PRECISIONinto a localSQLSMALLINTand widen-assign it into*column_size_ptr.decimal_digitsscale and datetime-precision paths: passsizeof(SQLSMALLINT)instead ofsizeof(SQLULEN).Are these changes tested?
Yes.
Are there any user-facing changes?
SQLDescribeColnow returns a correctcolumn_sizefor numeric/decimalcolumns instead of a value with uninitialized high bytes.