Skip to content

Avoid calling deprecated ODBC functions #17556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Jan 24, 2025

SQLGetConnectOption, SQLSetConnectOption and SQLSetStmtOption are deprecated, so if ODBC 3 is available, we use SQLSetConnectAttr, SQLGetConnectAttr, and SQLSetStmtAttr instead.


I'm not quite sure how to actually handle this best. Assuming that we won't require ODBC >= 3, some of the error messages would need to be adapted (e.g. we should not report an issue with SQLConnectOption, when we actually called SQLSetConnectAttr. Furthermore, the generic replacement in odbc_setoption() might be too presumptious (from looking at sqlext.h, it seems to be okay, but who knows). Possibly, we should deprecate this PHP function altogether (at least the docs could need some update).

However, if on a particular job it can make PHP work so your boss doesn't tell you to use a commercial product, that's all that really matters.

¯\(ツ)

A possible alternative to the PR as is would be to introduce general shims as macros, but this might cause even more confusion.

Anyhow, we should have a look at the double casts (SQLPOINTER) (intptr_t) (without, Clang 18.1.8 complains); we should probably use integer types which have the same size as a pointer in the first place.

@NattyNarwhal
Copy link
Member

I'm wondering when ODBCVER wouldn't be 3.x. Latest unixODBC and iODBC are at 0x0351 for 3.5.1, latest Windows is at 0x380 for 3.8. Even using the weird building it with Db2's SQL/CLI driver directly option, the latest version of that says it's 3.8 as well. Maybe the old crusty ODBC drivers don't do ODBC 3, but we could drop these, see GH-15630/GH-15737.

That said, individual drivers might not support all the functionality, but if we're building against a driver manager as we should, it should handle that for us.

@cmb69
Copy link
Member Author

cmb69 commented Jan 25, 2025

Yeah, I think pursuing #15630/#15727 is overdue.

And I've noticed that the ODBC cursor library is deprecated (SQL_CUR_USE_IF_NEEDED and SQL_CUR_USE_ODBC), and scheduled for removal. We should probably deprecate $cursor_option of odbc_(p)connect(), and the respective userland constants as soon as possible.

`SQLGetConnectOption`, `SQLSetConnectOption` and `SQLSetStmtOption` are
deprecated, so if ODBC 3 is available, we use `SQLSetConnectAttr`,
`SQLGetConnectAttr`, and `SQLSetStmtAttr` instead.
@cmb69 cmb69 force-pushed the cmb/odbc-deprecated branch from 743bec7 to 072062e Compare January 25, 2025 17:42
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.

2 participants