From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 61 ++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 10 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 3d89687e5f7..16539130663 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3807,6 +3807,37 @@ SQLRETURN WINAPI SQLParamOptions(SQLHSTMT StatementHandle, SQLULEN RowCount, SQL return ret; }
+static SQLRETURN primary_keys_unix_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3 ) +{ + struct SQLPrimaryKeys_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3 }; + return ODBC_CALL( SQLPrimaryKeys, ¶ms ); +} + +static SQLRETURN primary_keys_win32_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3 ) +{ + WCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLPrimaryKeys) + return handle->win32_funcs->SQLPrimaryKeys( handle->win32_handle, catalog, len1, schema, len2, table, len3 ); + + if (handle->win32_funcs->SQLPrimaryKeysW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) goto done; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + ret = handle->win32_funcs->SQLPrimaryKeysW( handle->win32_handle, catalogW, len1, schemaW, len2, tableW, len3 ); + } + +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + return ret; +} + /************************************************************************* * SQLPrimaryKeys [ODBC32.065] */ @@ -3826,14 +3857,11 @@ SQLRETURN WINAPI SQLPrimaryKeys(SQLHSTMT StatementHandle, SQLCHAR *CatalogName,
if (handle->unix_handle) { - struct SQLPrimaryKeys_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3 }; - ret = ODBC_CALL( SQLPrimaryKeys, ¶ms ); + ret = primary_keys_unix_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLPrimaryKeys( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3 ); + ret = primary_keys_win32_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3 ); }
TRACE("Returning %d\n", ret); @@ -5778,6 +5806,22 @@ SQLRETURN WINAPI SQLNativeSqlW(SQLHDBC ConnectionHandle, SQLWCHAR *InStatementTe return ret; }
+static SQLRETURN primary_keys_unix_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3 ) +{ + struct SQLPrimaryKeysW_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3 }; + return ODBC_CALL( SQLPrimaryKeysW, ¶ms ); +} + +static SQLRETURN primary_keys_win32_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3 ) +{ + if (handle->win32_funcs->SQLPrimaryKeysW) + return handle->win32_funcs->SQLPrimaryKeysW( handle->win32_handle, catalog, len1, schema, len2, table, len3 ); + if (handle->win32_funcs->SQLPrimaryKeys) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLPrimaryKeysW [ODBC32.165] */ @@ -5797,14 +5841,11 @@ SQLRETURN WINAPI SQLPrimaryKeysW(SQLHSTMT StatementHandle, SQLWCHAR *CatalogName
if (handle->unix_handle) { - struct SQLPrimaryKeysW_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength2 }; - ret = ODBC_CALL( SQLPrimaryKeysW, ¶ms ); + ret = primary_keys_unix_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength2 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLPrimaryKeysW( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength2 ); + ret = primary_keys_win32_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength2 ); }
TRACE("Returning %d\n", ret);