From 5b0d40664db4bec5a4aa77d97986e4540d18c9af Mon Sep 17 00:00:00 2001 From: Joe Nahmias Date: Wed, 18 Nov 2026 11:12:53 -0500 Subject: [PATCH 1/2] PDO_ODBC: fallback when SQLDescribeParam returns SQL_UNKNOWN_TYPE 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 3120ca8e46d107553ab00563685c0aab2ebd5dc7) --- ext/pdo_odbc/odbc_stmt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 042c4684a887..d0af8c38f0af 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -387,12 +387,20 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p } rc = SQLDescribeParam(S->stmt, (SQLUSMALLINT) param->paramno+1, &sqltype, &precision, &scale, &nullable); - if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + if ( + (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) + || sqltype == SQL_UNKNOWN_TYPE + ) { /* MS Access, for instance, doesn't support SQLDescribeParam, * so we need to guess */ + precision = 4000; + scale = 5; + nullable = 1; switch (PDO_PARAM_TYPE(param->param_type)) { case PDO_PARAM_INT: sqltype = SQL_INTEGER; + precision = 10; + scale = 0; break; case PDO_PARAM_LOB: sqltype = SQL_LONGVARBINARY; @@ -400,9 +408,6 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p default: sqltype = SQL_LONGVARCHAR; } - precision = 4000; - scale = 5; - nullable = 1; if (param->max_value_len > 0) { precision = param->max_value_len; From cdd62298f6c360cdce24ec9f8f03a78e34820462 Mon Sep 17 00:00:00 2001 From: Joe Nahmias Date: Thu, 19 Nov 2026 09:13:58 -0500 Subject: [PATCH 2/2] gh25569: remove unneeded setting of precision/scale Leftover from debugging subsequent FreeTDS issue. --- ext/pdo_odbc/odbc_stmt.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index d0af8c38f0af..71d66fefdbfd 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -393,14 +393,9 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p ) { /* MS Access, for instance, doesn't support SQLDescribeParam, * so we need to guess */ - precision = 4000; - scale = 5; - nullable = 1; switch (PDO_PARAM_TYPE(param->param_type)) { case PDO_PARAM_INT: sqltype = SQL_INTEGER; - precision = 10; - scale = 0; break; case PDO_PARAM_LOB: sqltype = SQL_LONGVARBINARY; @@ -408,6 +403,9 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p default: sqltype = SQL_LONGVARCHAR; } + precision = 4000; + scale = 5; + nullable = 1; if (param->max_value_len > 0) { precision = param->max_value_len;