From 098710805c2ae8a40afa83e2e959e7bb7e3bd5f1 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Fri, 31 May 2024 18:34:23 -0300 Subject: [PATCH 1/2] Remove usage of SDWORD, replace with SQLINTEGER Some different driver managers disagree if this should be 4 or 8 bytes in size. SQLGetDiagRec expects this to be an SQLINTEGER, so we should just use that explicitly instead of hoping that it's the same size. Fixes GH-14367 --- ext/pdo_odbc/php_pdo_odbc_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index 6f1b99b0c5a29..21a1539ac1a02 100644 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -116,7 +116,7 @@ typedef struct { char last_state[6]; char last_err_msg[SQL_MAX_MESSAGE_LENGTH]; - SDWORD last_error; + SQLINTEGER last_error; const char *file, *what; int line; } pdo_odbc_errinfo; From 8c3ae138bca55d599951552cbd3ceda59cf05da3 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Fri, 31 May 2024 18:35:47 -0300 Subject: [PATCH 2/2] Replace SWORD with SQLSMALLINT While this hasn't caused issues like the SQLINTEGER/SDWORD confusion has, we should use what SQLDescrimeParam calls for, which is SQLSMALLINT. --- ext/pdo_odbc/odbc_stmt.c | 6 +++--- ext/pdo_odbc/php_pdo_odbc_int.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index ea0dd0e53aac6..bd4a2f6162d09 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -32,7 +32,7 @@ enum pdo_odbc_conv_result { PDO_ODBC_CONV_FAIL }; -static int pdo_odbc_sqltype_is_unicode(pdo_odbc_stmt *S, SWORD sqltype) +static int pdo_odbc_sqltype_is_unicode(pdo_odbc_stmt *S, SQLSMALLINT sqltype) { if (!S->assume_utf8) return 0; switch (sqltype) { @@ -287,7 +287,7 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p { pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; RETCODE rc; - SWORD sqltype = 0, ctype = 0, scale = 0, nullable = 0; + SQLSMALLINT sqltype = 0, ctype = 0, scale = 0, nullable = 0; SQLULEN precision = 0; pdo_odbc_param *P; zval *parameter; @@ -563,7 +563,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno) pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data; struct pdo_column_data *col = &stmt->columns[colno]; RETCODE rc; - SWORD colnamelen; + SQLSMALLINT colnamelen; SQLULEN colsize; SQLLEN displaysize = 0; diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index 21a1539ac1a02..0a453a0023f8b 100644 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -133,7 +133,7 @@ typedef struct { char *data; zend_ulong datalen; SQLLEN fetched_len; - SWORD coltype; + SQLSMALLINT coltype; char colname[128]; unsigned is_long; unsigned is_unicode:1;