From 00546bc9b7cb8208c27de9c6ebd12156401a5607 Mon Sep 17 00:00:00 2001 From: Keyur Govande Date: Mon, 28 Jul 2014 23:15:23 +0000 Subject: Fix bug #60616 (odbc_fetch_into returns junk at end of multi-byte char fields) The ODBC extension did not support WVARCHAR. WVARCHAR ends up being handled by the default handler where vallen is set by the driver to the actual bytes needed for the field. If it is larger than default-lrl then the output is corrupted (reading past the buffer) because the return functions don't expect that to happen. The patch add support to handle WVARCHAR just like a regular VARCHAR. --- ext/odbc/php_odbc_includes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/odbc/php_odbc_includes.h') diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h index a9b0acfa0c..b3ae889974 100644 --- a/ext/odbc/php_odbc_includes.h +++ b/ext/odbc/php_odbc_includes.h @@ -284,7 +284,7 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC); void odbc_sql_error(ODBC_SQL_ERROR_PARAMS); -#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR) +#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WVARCHAR || x == SQL_WLONGVARCHAR) #define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY) #ifdef ZTS -- cgit v1.2.1 From 65364fe7d00319f6bfb4814980988d34183f9f78 Mon Sep 17 00:00:00 2001 From: Keyur Govande Date: Wed, 30 Jul 2014 02:28:31 +0000 Subject: Corrected patch for bug #60616 For unixODBC, use ODBC version as defined by it (as of v2.2.14 it is 3.5). This allows us to use newer features like SQL_DESC_OCTET_LENGTH (which returns the number of bytes required to store the data). This fixes the issue in #60616. If the newer version is not available, over-allocate to accomodate 4-byte Unicode characters for CHAR and VARCHAR datatypes (and their Wide counterparts). version. Fixed a couple of failing tests. --- ext/odbc/php_odbc_includes.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ext/odbc/php_odbc_includes.h') diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h index b3ae889974..06113d9624 100644 --- a/ext/odbc/php_odbc_includes.h +++ b/ext/odbc/php_odbc_includes.h @@ -115,6 +115,7 @@ PHP_FUNCTION(solid_fetch_prev); #endif #define ODBC_TYPE "unixODBC" +#undef ODBCVER #include #include #define HAVE_SQL_EXTENDED_FETCH 1 @@ -284,7 +285,11 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC); void odbc_sql_error(ODBC_SQL_ERROR_PARAMS); -#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WVARCHAR || x == SQL_WLONGVARCHAR) +#if defined(ODBCVER) && (ODBCVER >= 0x0300) +#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WLONGVARCHAR) +#else +#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR) +#endif #define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY) #ifdef ZTS -- cgit v1.2.1