Skip to content

Conversation

alinaliBQ
Copy link
Contributor

@alinaliBQ alinaliBQ commented Oct 8, 2025

Rationale for this change

ODBC needs to provide diagnostic information so users can debug the error

What changes are included in this PR?

Are these changes tested?

The build will be checked in CI when PR is ready for review.
Tests will be in a separate PR (see #47764). Other APIs depend on SQLGetDiagField and SQLGetDiagRec to get error reporting functionality, and tests for SQLGetDiagField and SQLGetDiagRec depend on other APIs for creating errors, as these diagnostic APIs alone do not initiate any errors.

Are there any user-facing changes?

No

@alinaliBQ alinaliBQ changed the title GH-46096: [C++][FlightRPC] ODBC Diagnostics Report GH-46575: [C++][FlightRPC] ODBC Diagnostics Report Oct 8, 2025
@github-actions github-actions bot added the awaiting review Awaiting review label Oct 8, 2025
Copy link

github-actions bot commented Oct 8, 2025

⚠️ GitHub issue #46575 has been automatically assigned in GitHub to PR creator.

@alinaliBQ
Copy link
Contributor Author

alinaliBQ commented Oct 8, 2025

@lidavidm @kou Please review this draft ODBC API PR. The test PR is at #47764.

Tests will be in a separate PR (see #47764). Other APIs depend on SQLGetDiagField and SQLGetDiagRec to get error reporting functionality, and tests for SQLGetDiagField and SQLGetDiagRec depend on other APIs for creating errors, as these diagnostic APIs alone do not initiate any errors.

// The length of the sql state is always 5 characters plus null
SQLSMALLINT size = 6;
const std::string& state = diagnostics->GetSQLState(record_index);
GetStringAttribute(is_unicode, state, false, sql_state, size, &size, *diagnostics);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to check the return value?

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Oct 9, 2025
SQLSMALLINT* string_length_ptr, bool is_unicode) {
const SQLSMALLINT char_size = is_unicode ? GetSqlWCharSize() : sizeof(char);
const bool has_valid_buffer =
diag_info_ptr && buffer_length >= 0 && buffer_length % char_size == 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need diag_info_ptr && here?

Suggested change
diag_info_ptr && buffer_length >= 0 && buffer_length % char_size == 0;
buffer_length >= 0 && buffer_length % char_size == 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants