Skip to content

Conversation

@alinaliBQ
Copy link
Contributor

@alinaliBQ alinaliBQ commented Oct 8, 2025

Rationale for this change

ODBC driver needs to handle environment handle and connection handle allocation and deallocation.

What changes are included in this PR?

  • Implement SQLAllocHandle and SQLFreeHandle APIs for allocating and deallocating environment and connection handles.
  • Tests

Are these changes tested?

Are there any user-facing changes?

No

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

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

@alinaliBQ
Copy link
Contributor Author

@lidavidm @kou Please review this draft ODBC API PR. The testing folder structure will be in a separate PR

SQLHENV env;

// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
Copy link
Member

Choose a reason for hiding this comment

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

Should we check the return code? (Should we free the result?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, added check and freed the result

namespace arrow::flight::sql::odbc {

TEST(SQLAllocHandle, TestSQLAllocHandleEnv) {
// ODBC Environment
Copy link
Member

Choose a reason for hiding this comment

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

nit: I don't think these comments add much

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove ODBC environment comment


TEST(SQLAllocEnv, TestSQLAllocEnv) {
// ODBC Environment
SQLHENV env;
Copy link
Member

Choose a reason for hiding this comment

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

ditto, should we check/free the result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added calls to free the result

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Oct 8, 2025
Copy link
Contributor Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

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

We are working on the comments

alinaliBQ added a commit to Bit-Quill/arrow that referenced this pull request Oct 16, 2025
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 16, 2025
alinaliBQ added a commit to Bit-Quill/arrow that referenced this pull request Oct 20, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46096-sql-alloc-env branch 2 times, most recently from 85b1b11 to 21ba2a1 Compare October 20, 2025 22:17
Copy link
Contributor Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

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

Addressed all code review comments

SQLHENV env;

// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, added check and freed the result

namespace arrow::flight::sql::odbc {

TEST(SQLAllocHandle, TestSQLAllocHandleEnv) {
// ODBC Environment
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove ODBC environment comment


TEST(SQLAllocEnv, TestSQLAllocEnv) {
// ODBC Environment
SQLHENV env;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added calls to free the result

@alinaliBQ alinaliBQ requested review from kou and lidavidm October 20, 2025 22:18
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 20, 2025
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 21, 2025
@alinaliBQ alinaliBQ force-pushed the gh-46096-sql-alloc-env branch from abc38d9 to 6d0570a Compare October 21, 2025 18:00
Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

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

Please rebase!

Comment on lines 29 to 33
template <typename T>
class ConnectionTest : public T {
public:
using List = std::list<T>;
};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
template <typename T>
class ConnectionTest : public T {
public:
using List = std::list<T>;
};
template <typename T>
class ConnectionTest : public T {
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebased and removed using List

* Tests will be added in separate PRs

Add tests for SQLAllocEnv and SQLAllocConnect

* Other test structure code will be in a separate PR

Add comment

Add comment from apache#47759 (comment)

Work on code review comments

Add test fixture for file

Co-Authored-By: justing-bq <[email protected]>

Add comment for `ConnectionRemoteTest`

Add comment for `ReleaseConnection`
@alinaliBQ alinaliBQ force-pushed the gh-46096-sql-alloc-env branch from 6d0570a to 906f413 Compare October 22, 2025 18:29
Copy link
Contributor Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

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

Addressed comment. I ran the tests locally and they passed. Marking PR as ready for review. Changes in this PR will be tested in CI after #47689 is merged

Comment on lines 29 to 33
template <typename T>
class ConnectionTest : public T {
public:
using List = std::list<T>;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebased and removed using List

@alinaliBQ alinaliBQ marked this pull request as ready for review October 22, 2025 18:33
@alinaliBQ alinaliBQ requested a review from lidavidm October 22, 2025 23:09
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Oct 22, 2025
@lidavidm lidavidm merged commit 62afc09 into apache:main Oct 23, 2025
47 of 49 checks passed
@lidavidm lidavidm removed the awaiting merge Awaiting merge label Oct 23, 2025
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 62afc09.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 4 possible false positives for unstable benchmarks that are known to sometimes produce them.

zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Nov 5, 2025
…location (apache#47759)

### Rationale for this change
ODBC driver needs to handle environment handle and connection handle allocation and deallocation.

### What changes are included in this PR?
- Implement SQLAllocHandle and SQLFreeHandle APIs for allocating and deallocating environment and connection handles.
- Tests

### Are these changes tested?
- Tested locally on Windows MSVC.
- Will be tested in CI after apache#47689 is merged

### Are there any user-facing changes?
No
* GitHub Issue: apache#46096
* GitHub Issue: apache#46097 

Authored-by: Alina (Xi) Li <[email protected]>
Signed-off-by: David Li <[email protected]>
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