Skip to content

ext/pdo_odbc fallback when SQLDescribeParam returns SQL_UNKNOWN_TYPE - #25569

Open
jnahmias wants to merge 2 commits into
php:masterfrom
jnahmias:pdo_odbc_param
Open

jnahmias wants to merge 2 commits into
php:masterfrom
jnahmias:pdo_odbc_param

Conversation

@jnahmias

Copy link
Copy Markdown

Some ODBC drivers, eg. FreeTDS, report SQL_SUCCESS from SQLDescribeParam() while leaving sqltype as SQL_UNKNOWN_TYPE (0).

Treat SQL_UNKNOWN_TYPE the same as a failed SQLDescribeParam() call and fall back to PDO parameter type inference instead of passing sqltype=0 to SQLBindParameter().

Some ODBC drivers may report SQL_SUCCESS from SQLDescribeParam()
while leaving sqltype as SQL_UNKNOWN_TYPE (0).

Treat SQL_UNKNOWN_TYPE the same as a failed SQLDescribeParam()
call and fall back to PDO parameter type inference instead of
passing sqltype=0 to SQLBindParameter().

(cherry picked from commit 3120ca8)
@jnahmias

jnahmias commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

Prior to this patch, ext/pdo_odbc/tests/bug44643.phpt fails with HY004 Invalid SQL data type because SQLDescribeParam() may report success while returning SQL_UNKNOWN_TYPE. PDO_ODBC treats this value as valid and propagates it into SQLBindParameter(), resulting in the HY004 error.

After this patch, PDO_ODBC falls back to its existing parameter type inference logic, SQLBindParameter() succeeds and execution progresses into a separate FreeTDS issue (HY090 Invalid string or buffer length), tracked in FreeTDS/freetds#743.

Comment thread ext/pdo_odbc/odbc_stmt.c Resolved
Leftover from debugging subsequent FreeTDS issue.
@jnahmias

Copy link
Copy Markdown
Author

feel free to squash if that makes more sense

@NattyNarwhal

Copy link
Copy Markdown
Member

Are the other values also invalid are is it just the type being SQL_UNKNOWN_TYPE?

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