From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 80 ++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 12 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index b71ef7aac42..0602182090a 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -684,7 +684,7 @@ static SQLRETURN col_attribute_win32_a( struct handle *handle, SQLUSMALLINT col, return handle->win32_funcs->SQLColAttribute( handle->win32_handle, col, field_id, char_attr, buflen, retlen, num_attr ); } - else if (handle->win32_funcs->SQLColAttributeW) + if (handle->win32_funcs->SQLColAttributeW) { if (buflen < 0) ret = handle->win32_funcs->SQLColAttributeW( handle->win32_handle, col, field_id, char_attr, buflen, @@ -2874,7 +2874,7 @@ static SQLRETURN col_attributes_win32_a( struct handle *handle, SQLUSMALLINT col return handle->win32_funcs->SQLColAttributes( handle->win32_handle, col, field_id, char_attrs, buflen, retlen, num_attrs ); } - else if (handle->win32_funcs->SQLColAttributesW) + if (handle->win32_funcs->SQLColAttributesW) { if (buflen < 0) ret = handle->win32_funcs->SQLColAttributesW( handle->win32_handle, col, field_id, char_attrs, buflen, @@ -2929,6 +2929,44 @@ SQLRETURN WINAPI SQLColAttributes(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnN return ret; }
+static SQLRETURN column_privs_unix_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *column, + SQLSMALLINT len4 ) +{ + struct SQLColumnPrivileges_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, + column, len4 }; + return ODBC_CALL( SQLColumnPrivileges, ¶ms ); +} + +static SQLRETURN column_privs_win32_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *column, + SQLSMALLINT len4 ) +{ + SQLWCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL, *columnW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLColumnPrivileges) + { + return handle->win32_funcs->SQLColumnPrivileges( handle->win32_handle, catalog, len1, schema, len2, table, + len3, column, len4 ); + } + if (handle->win32_funcs->SQLColumnPrivilegesW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) return SQL_ERROR; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + if (!(columnW = strnAtoW( column, len4 ))) goto done; + ret = handle->win32_funcs->SQLColumnPrivilegesW( handle->win32_handle, catalogW, len1, schemaW, len2, tableW, + len3, columnW, len4 ); + } +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + free( columnW ); + return ret; +} + /************************************************************************* * SQLColumnPrivileges [ODBC32.056] */ @@ -2949,14 +2987,13 @@ SQLRETURN WINAPI SQLColumnPrivileges(SQLHSTMT StatementHandle, SQLCHAR *CatalogN
if (handle->unix_handle) { - struct SQLColumnPrivileges_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, ColumnName, NameLength4 }; - ret = ODBC_CALL( SQLColumnPrivileges, ¶ms ); + ret = column_privs_unix_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLColumnPrivileges( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, ColumnName, NameLength4 ); + ret = column_privs_win32_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); }
TRACE("Returning %d\n", ret); @@ -4689,6 +4726,26 @@ done: return ret; }
+static SQLRETURN column_privs_unix_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLWCHAR *column, + SQLSMALLINT len4 ) +{ + struct SQLColumnPrivilegesW_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, + column, len4 }; + return ODBC_CALL( SQLColumnPrivilegesW, ¶ms ); +} + +static SQLRETURN column_privs_win32_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLWCHAR *column, + SQLSMALLINT len4 ) +{ + if (handle->win32_funcs->SQLColumnPrivilegesW) + return handle->win32_funcs->SQLColumnPrivilegesW( handle->win32_handle, catalog, len1, schema, len2, table, + len3, column, len4 ); + if (handle->win32_funcs->SQLColumnPrivileges) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLColumnPrivilegesW [ODBC32.156] */ @@ -4709,14 +4766,13 @@ SQLRETURN WINAPI SQLColumnPrivilegesW(SQLHSTMT StatementHandle, SQLWCHAR *Catalo
if (handle->unix_handle) { - struct SQLColumnPrivilegesW_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, ColumnName, NameLength4 }; - ret = ODBC_CALL( SQLColumnPrivilegesW, ¶ms ); + ret = column_privs_unix_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLColumnPrivilegesW( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, ColumnName, NameLength4 ); + ret = column_privs_win32_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 114 +++++++++++++++++++++++++++++----------- 1 file changed, 84 insertions(+), 30 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 0602182090a..0e2020506ee 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -745,6 +745,60 @@ static const char *debugstr_sqlstr( const SQLCHAR *str, SQLSMALLINT len ) return wine_dbgstr_an( (const char *)str, len ); }
+static SQLWCHAR *strnAtoW( const SQLCHAR *str, int len ) +{ + SQLWCHAR *ret; + int lenW; + + if (!str) return NULL; + + if (len == SQL_NTS) len = strlen( (const char *)str ); + lenW = MultiByteToWideChar( CP_ACP, 0, (const char *)str, len, NULL, 0 ); + if ((ret = malloc( (lenW + 1) * sizeof(SQLWCHAR) ))) + { + MultiByteToWideChar( CP_ACP, 0, (const char *)str, len, ret, lenW ); + ret[lenW] = 0; + } + return ret; +} + +static SQLRETURN columns_unix_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *column, + SQLSMALLINT len4 ) +{ + struct SQLColumns_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, column, len4 }; + return ODBC_CALL( SQLColumns, ¶ms ); +} + +static SQLRETURN columns_win32_a( struct handle *handle, SQLCHAR *catalog, SQLSMALLINT len1, SQLCHAR *schema, + SQLSMALLINT len2, SQLCHAR *table, SQLSMALLINT len3, SQLCHAR *column, + SQLSMALLINT len4 ) +{ + SQLWCHAR *catalogW = NULL, *schemaW = NULL, *tableW = NULL, *columnW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLColumns) + { + return handle->win32_funcs->SQLColumns( handle->win32_handle, catalog, len1, schema, len2, table, len3, + column, len4 ); + } + if (handle->win32_funcs->SQLColumnsW) + { + if (!(catalogW = strnAtoW( catalog, len1 ))) return SQL_ERROR; + if (!(schemaW = strnAtoW( schema, len2 ))) goto done; + if (!(tableW = strnAtoW( table, len3 ))) goto done; + if (!(columnW = strnAtoW( column, len4 ))) goto done; + ret = handle->win32_funcs->SQLColumnsW( handle->win32_handle, catalogW, len1, schemaW, len2, tableW, len3, + columnW, len4 ); + } +done: + free( catalogW ); + free( schemaW ); + free( tableW ); + free( columnW ); + return ret; +} + /************************************************************************* * SQLColumns [ODBC32.040] */ @@ -765,14 +819,13 @@ SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle, SQLCHAR *CatalogName, SQLS
if (handle->unix_handle) { - struct SQLColumns_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, ColumnName, NameLength4 }; - ret = ODBC_CALL( SQLColumns, ¶ms ); + ret = columns_unix_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLColumns( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, ColumnName, NameLength4 ); + ret = columns_win32_a( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); }
TRACE("Returning %d\n", ret); @@ -2713,23 +2766,6 @@ static WCHAR *get_datasource( const WCHAR *connection_string ) return ret; }
-static WCHAR *strnAtoW( const SQLCHAR *str, int len ) -{ - WCHAR *ret; - int lenW; - - if (!str) return NULL; - - if (len == SQL_NTS) len = strlen( (const char *)str ); - lenW = MultiByteToWideChar( CP_ACP, 0, (const char *)str, len, NULL, 0 ); - if ((ret = malloc( (lenW + 1) * sizeof(WCHAR) ))) - { - MultiByteToWideChar( CP_ACP, 0, (const char *)str, len, ret, lenW ); - ret[lenW] = 0; - } - return ret; -} - static SQLRETURN browse_connect_win32_a( struct handle *handle, SQLCHAR *in_conn_str, SQLSMALLINT inlen, SQLCHAR *out_conn_str, SQLSMALLINT buflen, SQLSMALLINT *outlen ) { @@ -4304,12 +4340,31 @@ SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribu return ret; }
+static SQLRETURN columns_unix_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLWCHAR *column, + SQLSMALLINT len4 ) +{ + struct SQLColumnsW_params params = { handle->unix_handle, catalog, len1, schema, len2, table, len3, column, len4 }; + return ODBC_CALL( SQLColumnsW, ¶ms ); +} + +static SQLRETURN columns_win32_w( struct handle *handle, SQLWCHAR *catalog, SQLSMALLINT len1, SQLWCHAR *schema, + SQLSMALLINT len2, SQLWCHAR *table, SQLSMALLINT len3, SQLWCHAR *column, + SQLSMALLINT len4 ) +{ + if (handle->win32_funcs->SQLColumnsW) + return handle->win32_funcs->SQLColumnsW( handle->win32_handle, catalog, len1, schema, len2, table, len3, + column, len4 ); + if (handle->win32_funcs->SQLColumns) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLColumnsW [ODBC32.140] */ -SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, WCHAR *CatalogName, SQLSMALLINT NameLength1, - WCHAR *SchemaName, SQLSMALLINT NameLength2, WCHAR *TableName, - SQLSMALLINT NameLength3, WCHAR *ColumnName, SQLSMALLINT NameLength4) +SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, SQLWCHAR *CatalogName, SQLSMALLINT NameLength1, + SQLWCHAR *SchemaName, SQLSMALLINT NameLength2, SQLWCHAR *TableName, + SQLSMALLINT NameLength3, SQLWCHAR *ColumnName, SQLSMALLINT NameLength4) { struct handle *handle = StatementHandle; SQLRETURN ret = SQL_ERROR; @@ -4324,14 +4379,13 @@ SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle, WCHAR *CatalogName, SQLSM
if (handle->unix_handle) { - struct SQLColumnsW_params params = { handle->unix_handle, CatalogName, NameLength1, SchemaName, NameLength2, - TableName, NameLength3, ColumnName, NameLength4 }; - ret = ODBC_CALL( SQLColumnsW, ¶ms ); + ret = columns_unix_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLColumnsW( handle->win32_handle, CatalogName, NameLength1, SchemaName, - NameLength2, TableName, NameLength3, ColumnName, NameLength4 ); + ret = columns_win32_w( handle, CatalogName, NameLength1, SchemaName, NameLength2, TableName, NameLength3, + ColumnName, NameLength4 ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 69 +++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 17 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 0e2020506ee..e9a00850803 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -989,6 +989,33 @@ static SQLRETURN create_con( struct handle *handle ) return prepare_con( handle ); }
+static SQLRETURN connect_win32_a( struct handle *handle, SQLCHAR *servername, SQLSMALLINT len1, SQLCHAR *username, + SQLSMALLINT len2, SQLCHAR *auth, SQLSMALLINT len3 ) +{ + SQLRETURN ret = SQL_ERROR; + SQLWCHAR *servernameW, *usernameW = NULL, *authW = NULL; + + if (handle->win32_funcs->SQLConnect) + return handle->win32_funcs->SQLConnect( handle->win32_handle, servername, len1, username, len2, auth, len3 ); + + if (!(servernameW = strnAtoW( servername, len1 ))) return SQL_ERROR; + if (!(usernameW = strnAtoW( username, len2 ))) goto done; + if (!(authW = strnAtoW( auth, len3 ))) goto done; + ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, servernameW, len1, usernameW, len2, authW, len3 ); +done: + free( servernameW ); + free( usernameW ); + free( authW ); + return ret; +} + +static SQLRETURN connect_unix_a( struct handle *handle, SQLCHAR *servername, SQLSMALLINT len1, SQLCHAR *username, + SQLSMALLINT len2, SQLCHAR *authentication, SQLSMALLINT len3 ) +{ + struct SQLConnect_params params = { handle->unix_handle, servername, len1, username, len2, authentication, len3 }; + return ODBC_CALL( SQLConnect, ¶ms ); +} + /************************************************************************* * SQLConnect [ODBC32.007] */ @@ -1025,20 +1052,16 @@ SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle, SQLCHAR *ServerName, SQLSM if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; if (!SUCCESS((ret = create_con( handle )))) goto done;
- ret = handle->win32_funcs->SQLConnect( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, - Authentication, NameLength3 ); + ret = connect_win32_a( handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); } else { - struct SQLConnect_params params = { 0, ServerName, NameLength1, UserName, NameLength2, Authentication, - NameLength3 }; - TRACE( "using Unix driver %s\n", debugstr_w(filename) ); + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; if (!SUCCESS((ret = create_con( handle )))) goto done;
- params.ConnectionHandle = handle->unix_handle; - ret = ODBC_CALL( SQLConnect, ¶ms ); + ret = connect_unix_a( handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); }
done: @@ -3751,8 +3774,24 @@ SQLRETURN WINAPI SQLColAttributesW(SQLHSTMT StatementHandle, SQLUSMALLINT Column
static const char *debugstr_sqlwstr( const SQLWCHAR *str, SQLSMALLINT len ) { - if (len == SQL_NTS) len = wcslen( (const WCHAR *)str ); - return wine_dbgstr_wn( (const WCHAR *)str, len ); + if (len == SQL_NTS) len = wcslen( str ); + return wine_dbgstr_wn( str, len ); +} + +static SQLRETURN connect_win32_w( struct handle *handle, SQLWCHAR *servername, SQLSMALLINT len1, SQLWCHAR *username, + SQLSMALLINT len2, SQLWCHAR *auth, SQLSMALLINT len3 ) +{ + if (handle->win32_funcs->SQLConnectW) + return handle->win32_funcs->SQLConnectW( handle->win32_handle, servername, len1, username, len2, auth, len3 ); + if (handle->win32_funcs->SQLConnect) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + +static SQLRETURN connect_unix_w( struct handle *handle, SQLWCHAR *servername, SQLSMALLINT len1, SQLWCHAR *username, + SQLSMALLINT len2, SQLWCHAR *auth, SQLSMALLINT len3 ) +{ + struct SQLConnectW_params params = { handle->unix_handle, servername, len1, username, len2, auth, len3 }; + return ODBC_CALL( SQLConnectW, ¶ms ); }
/************************************************************************* @@ -3791,20 +3830,16 @@ SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle, WCHAR *ServerName, SQLSMA if (!SUCCESS((ret = create_env( handle->parent, FALSE )))) goto done; if (!SUCCESS((ret = create_con( handle )))) goto done;
- ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, ServerName, NameLength1, UserName, NameLength2, - Authentication, NameLength3 ); + ret = connect_win32_w( handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); } else { - struct SQLConnectW_params params = { 0, ServerName, NameLength1, UserName, NameLength2, Authentication, - NameLength3 }; - TRACE( "using Unix driver %s\n", debugstr_w(filename) ); + if (!SUCCESS((ret = create_env( handle->parent, TRUE )))) goto done; if (!SUCCESS((ret = create_con( handle )))) goto done;
- params.ConnectionHandle = handle->unix_handle; - ret = ODBC_CALL( SQLConnectW, ¶ms ); + ret = connect_unix_w( handle, ServerName, NameLength1, UserName, NameLength2, Authentication, NameLength3 ); }
done: @@ -4465,7 +4500,7 @@ SQLRETURN WINAPI SQLDriverConnectW(SQLHDBC ConnectionHandle, SQLHWND WindowHandl if (!SUCCESS((ret = create_con( handle )))) goto done;
ret = driver_connect_unix_w( handle, WindowHandle, InConnectionString, Length, OutConnectionString, - BufferLength, Length2, DriverCompletion); + BufferLength, Length2, DriverCompletion ); }
done:
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 96 +++++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 18 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index e9a00850803..8c7291a21fc 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1181,6 +1181,50 @@ SQLRETURN WINAPI SQLDataSourcesA(SQLHENV EnvironmentHandle, SQLUSMALLINT Directi BufferLength2, NameLength2 ); }
+static SQLRETURN describe_col_unix_a( struct handle *handle, SQLUSMALLINT col_number, SQLCHAR *col_name, + SQLSMALLINT buflen, SQLSMALLINT *retlen, SQLSMALLINT *data_type, + SQLULEN *col_size, SQLSMALLINT *decimal_digits, SQLSMALLINT *nullable ) +{ + SQLRETURN ret; + SQLSMALLINT dummy; + UINT64 size; + struct SQLDescribeCol_params params = { handle->unix_handle, col_number, col_name, buflen, retlen, data_type, + &size, decimal_digits, nullable }; + if (!retlen) params.NameLength = &dummy; /* workaround for drivers that don't accept NULL NameLength */ + + if (SUCCESS((ret = ODBC_CALL( SQLDescribeCol, ¶ms ))) && col_size) *col_size = size; + return ret; +} + +static SQLRETURN describe_col_win32_a( struct handle *handle, SQLUSMALLINT col_number, SQLCHAR *col_name, + SQLSMALLINT buflen, SQLSMALLINT *retlen, SQLSMALLINT *data_type, + SQLULEN *col_size, SQLSMALLINT *decimal_digits, SQLSMALLINT *nullable ) +{ + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLDescribeCol) + { + return handle->win32_funcs->SQLDescribeCol( handle->win32_handle, col_number, col_name, buflen, retlen, + data_type, col_size, decimal_digits, nullable ); + } + if (handle->win32_funcs->SQLDescribeColW) + { + SQLWCHAR *nameW; + SQLSMALLINT lenW; + + if (!(nameW = malloc( buflen * sizeof(WCHAR) ))) return SQL_ERROR; + ret = handle->win32_funcs->SQLDescribeColW( handle->win32_handle, col_number, nameW, buflen, &lenW, + data_type, col_size, decimal_digits, nullable ); + if (SUCCESS( ret )) + { + int len = WideCharToMultiByte( CP_ACP, 0, nameW, -1, (char *)col_name, buflen, NULL, NULL ); + if (retlen) *retlen = len - 1; + } + free( nameW ); + } + return ret; +} + /************************************************************************* * SQLDescribeCol [ODBC32.008] */ @@ -1199,18 +1243,13 @@ SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNum
if (handle->unix_handle) { - UINT64 size; - SQLSMALLINT dummy; - struct SQLDescribeCol_params params = { handle->unix_handle, ColumnNumber, ColumnName, BufferLength, - NameLength, DataType, &size, DecimalDigits, Nullable }; - if (!params.NameLength) params.NameLength = &dummy; /* workaround for drivers that don't accept NULL NameLength */ - - if (SUCCESS((ret = ODBC_CALL( SQLDescribeCol, ¶ms ))) && ColumnSize) *ColumnSize = size; + ret = describe_col_unix_a( handle, ColumnNumber, ColumnName, BufferLength, NameLength, DataType, + ColumnSize, DecimalDigits, Nullable ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLDescribeCol( handle->win32_handle, ColumnNumber, ColumnName, BufferLength, - NameLength, DataType, ColumnSize, DecimalDigits, Nullable ); + ret = describe_col_win32_a( handle, ColumnNumber, ColumnName, BufferLength, NameLength, DataType, + ColumnSize, DecimalDigits, Nullable ); }
TRACE("Returning %d\n", ret); @@ -3848,6 +3887,32 @@ done: return ret; }
+static SQLRETURN describe_col_unix_w( struct handle *handle, SQLUSMALLINT col_number, SQLWCHAR *col_name, + SQLSMALLINT buf_len, SQLSMALLINT *name_len, SQLSMALLINT *data_type, + SQLULEN *col_size, SQLSMALLINT *decimal_digits, SQLSMALLINT *nullable ) +{ + SQLRETURN ret; + SQLSMALLINT dummy; + UINT64 size; + struct SQLDescribeColW_params params = { handle->unix_handle, col_number, col_name, buf_len, name_len, + data_type, &size, decimal_digits, nullable }; + if (!name_len) params.NameLength = &dummy; /* workaround for drivers that don't accept NULL NameLength */ + + if (SUCCESS((ret = ODBC_CALL( SQLDescribeColW, ¶ms ))) && col_size) *col_size = size; + return ret; +} + +static SQLRETURN describe_col_win32_w( struct handle *handle, SQLUSMALLINT col_number, SQLWCHAR *col_name, + SQLSMALLINT buf_len, SQLSMALLINT *name_len, SQLSMALLINT *data_type, + SQLULEN *col_size, SQLSMALLINT *decimal_digits, SQLSMALLINT *nullable ) +{ + if (handle->win32_funcs->SQLDescribeColW) + return handle->win32_funcs->SQLDescribeColW( handle->win32_handle, col_number, col_name, buf_len, name_len, + data_type, col_size, decimal_digits, nullable ); + if (handle->win32_funcs->SQLDescribeCol) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLDescribeColW [ODBC32.108] */ @@ -3866,18 +3931,13 @@ SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNu
if (handle->unix_handle) { - SQLSMALLINT dummy; - UINT64 size; - struct SQLDescribeColW_params params = { handle->unix_handle, ColumnNumber, ColumnName, BufferLength, - NameLength, DataType, &size, DecimalDigits, Nullable }; - if (!NameLength) params.NameLength = &dummy; /* workaround for drivers that don't accept NULL NameLength */ - - if (SUCCESS((ret = ODBC_CALL( SQLDescribeCol, ¶ms ))) && ColumnSize) *ColumnSize = size; + ret = describe_col_unix_w( handle, ColumnNumber, ColumnName, BufferLength, NameLength, DataType, + ColumnSize, DecimalDigits, Nullable ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLDescribeColW( handle->win32_handle, ColumnNumber, ColumnName, BufferLength, - NameLength, DataType, ColumnSize, DecimalDigits, Nullable ); + ret = describe_col_win32_w( handle, ColumnNumber, ColumnName, BufferLength, NameLength, DataType, + ColumnSize, DecimalDigits, Nullable ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 107 ++++++++++++++++++++++++++----------- dlls/odbc32/tests/odbc32.c | 19 +++++-- 2 files changed, 91 insertions(+), 35 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 8c7291a21fc..ee610bfc96d 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1308,6 +1308,47 @@ SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLIN return ret; }
+static SQLRETURN error_unix_a( struct handle *env, struct handle *con, struct handle *stmt, SQLCHAR *state, + SQLINTEGER *native_err, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *retlen ) +{ + struct SQLError_params params = { env ? env->unix_handle : 0, con ? con->unix_handle : 0, + stmt ? stmt->unix_handle : 0, state, native_err, msg, buflen, retlen }; + return ODBC_CALL( SQLError, ¶ms ); +} + +static SQLRETURN error_win32_a( struct handle *env, struct handle *con, struct handle *stmt, SQLCHAR *state, + SQLINTEGER *native_err, SQLCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *retlen ) +{ + const struct win32_funcs *win32_funcs; + SQLRETURN ret = SQL_ERROR; + + if (env) win32_funcs = env->win32_funcs; + else if (con) win32_funcs = con->win32_funcs; + else if (stmt) win32_funcs = stmt->win32_funcs; + + if (win32_funcs->SQLError) + return win32_funcs->SQLError( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL, + stmt ? stmt->win32_handle : NULL, state, native_err, msg, buflen, retlen ); + + if (win32_funcs->SQLErrorW) + { + SQLWCHAR stateW[6], *msgW = NULL; + SQLSMALLINT lenW; + + if (!(msgW = malloc( buflen * sizeof(SQLWCHAR) ))) return SQL_ERROR; + ret = win32_funcs->SQLErrorW( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL, + stmt ? stmt->win32_handle : NULL, stateW, native_err, msgW, buflen, &lenW ); + if (SUCCESS( ret )) + { + int len = WideCharToMultiByte( CP_ACP, 0, msgW, -1, (char *)msg, buflen, NULL, NULL ); + if (retlen) *retlen = len - 1; + WideCharToMultiByte( CP_ACP, 0, stateW, -1, (char *)state, 6, NULL, NULL ); + } + free( msgW ); + } + return ret; +} + /************************************************************************* * SQLError [ODBC32.010] */ @@ -1322,26 +1363,15 @@ SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, S " MessageText %p, BufferLength %d, TextLength %p)\n", EnvironmentHandle, ConnectionHandle, StatementHandle, SqlState, NativeError, MessageText, BufferLength, TextLength);
+ if (!env && !con && !stmt) return SQL_INVALID_HANDLE; + if ((env && env->unix_handle) || (con && con->unix_handle) || (stmt && stmt->unix_handle)) { - struct SQLError_params params = { env ? env->unix_handle : 0, - con ? con->unix_handle : 0, - stmt ? stmt->unix_handle : 0, - SqlState, NativeError, MessageText, BufferLength, TextLength }; - ret = ODBC_CALL( SQLError, ¶ms ); + ret = error_unix_a( env, con, stmt, SqlState, NativeError, MessageText, BufferLength, TextLength ); } else if ((env && env->win32_handle) || (con && con->win32_handle) || (stmt && stmt->win32_handle)) { - const struct win32_funcs *win32_funcs = NULL; - - if (env) win32_funcs = env->win32_funcs; - else if (con) win32_funcs = con->win32_funcs; - else if (stmt) win32_funcs = stmt->win32_funcs; - - ret = win32_funcs->SQLError( env ? env->win32_handle : NULL, - con ? con->win32_handle : NULL, - stmt ? stmt->win32_handle : NULL, - SqlState, NativeError, MessageText, BufferLength, TextLength ); + ret = error_win32_a( env, con, stmt, SqlState, NativeError, MessageText, BufferLength, TextLength ); }
if (SUCCESS( ret )) @@ -3944,11 +3974,35 @@ SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNu return ret; }
+static SQLRETURN error_unix_w( struct handle *env, struct handle *con, struct handle *stmt, SQLWCHAR *state, + SQLINTEGER *native_err, SQLWCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *retlen ) +{ + struct SQLErrorW_params params = { env ? env->unix_handle : 0, con ? con->unix_handle : 0, + stmt ? stmt->unix_handle : 0, state, native_err, msg, buflen, retlen }; + return ODBC_CALL( SQLErrorW, ¶ms ); +} + +static SQLRETURN error_win32_w( struct handle *env, struct handle *con, struct handle *stmt, SQLWCHAR *state, + SQLINTEGER *native_err, SQLWCHAR *msg, SQLSMALLINT buflen, SQLSMALLINT *retlen ) +{ + const struct win32_funcs *win32_funcs; + + if (env) win32_funcs = env->win32_funcs; + else if (con) win32_funcs = con->win32_funcs; + else if (stmt) win32_funcs = stmt->win32_funcs; + + if (win32_funcs->SQLErrorW) + return win32_funcs->SQLErrorW( env ? env->win32_handle : NULL, con ? con->win32_handle : NULL, + stmt ? stmt->win32_handle : NULL, state, native_err, msg, buflen, retlen ); + if (win32_funcs->SQLError) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLErrorW [ODBC32.110] */ SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle, - WCHAR *SqlState, SQLINTEGER *NativeError, WCHAR *MessageText, + SQLWCHAR *SqlState, SQLINTEGER *NativeError, SQLWCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength) { struct handle *env = EnvironmentHandle, *con = ConnectionHandle, *stmt = StatementHandle; @@ -3958,29 +4012,18 @@ SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, " MessageText %p, BufferLength %d, TextLength %p)\n", EnvironmentHandle, ConnectionHandle, StatementHandle, SqlState, NativeError, MessageText, BufferLength, TextLength);
+ if (!env && !con && !stmt) return SQL_INVALID_HANDLE; + if ((env && env->unix_handle) || (con && con->unix_handle) || (stmt && stmt->unix_handle)) { - struct SQLErrorW_params params = { env ? env->unix_handle : 0, - con ? con->unix_handle : 0, - stmt ? stmt->unix_handle : 0, - SqlState, NativeError, MessageText, BufferLength, TextLength }; - ret = ODBC_CALL( SQLErrorW, ¶ms ); + ret = error_unix_w( env, con, stmt, SqlState, NativeError, MessageText, BufferLength, TextLength ); } else if ((env && env->win32_handle) || (con && con->win32_handle) || (stmt && stmt->win32_handle)) { - const struct win32_funcs *win32_funcs = NULL; - - if (env) win32_funcs = env->win32_funcs; - else if (con) win32_funcs = con->win32_funcs; - else if (stmt) win32_funcs = stmt->win32_funcs; - - ret = win32_funcs->SQLErrorW( env ? env->win32_handle : NULL, - con ? con->win32_handle : NULL, - stmt ? stmt->win32_handle : NULL, - SqlState, NativeError, MessageText, BufferLength, TextLength ); + ret = error_win32_w( env, con, stmt, SqlState, NativeError, MessageText, BufferLength, TextLength ); }
- if (SUCCESS(ret )) + if (SUCCESS( ret )) { TRACE(" SqlState %s\n", debugstr_sqlwstr(SqlState, 5)); TRACE(" Error %d\n", *NativeError); diff --git a/dlls/odbc32/tests/odbc32.c b/dlls/odbc32/tests/odbc32.c index f960ab5aabe..9293b98b049 100644 --- a/dlls/odbc32/tests/odbc32.c +++ b/dlls/odbc32/tests/odbc32.c @@ -66,7 +66,7 @@ static void diag( SQLHANDLE handle, SQLSMALLINT type ) { SQLINTEGER err; SQLSMALLINT len; - SQLCHAR state[5], msg[256]; + SQLCHAR state[6], msg[256]; SQLRETURN ret;
state[0] = 0; @@ -301,8 +301,9 @@ static void test_SQLExecDirect( void ) SQLRETURN ret; SQLLEN count, len_id[2], len_name[2]; SQLULEN rows_fetched; - SQLINTEGER id[2]; - SQLCHAR name[32]; + SQLINTEGER id[2], err; + SQLCHAR name[32], msg[32], state[6]; + SQLSMALLINT len;
ret = SQLAllocEnv( &env ); ok( ret == SQL_SUCCESS, "got %d\n", ret ); @@ -449,6 +450,18 @@ static void test_SQLExecDirect( void ) ret = SQLExecDirect( stmt, (SQLCHAR *)"DROP TABLE winetest", ARRAYSIZE("DROP TABLE winetest") - 1 ); ok( ret == SQL_SUCCESS, "got %d\n", ret );
+ ret = SQLError( NULL, NULL, NULL, state, &err, msg, sizeof(msg), &len ); + ok( ret == SQL_INVALID_HANDLE, "got %d\n", ret ); + + ret = SQLError( env, NULL, NULL, state, &err, msg, sizeof(msg), &len ); + ok( ret == SQL_NO_DATA, "got %d\n", ret ); + + ret = SQLError( env, con, NULL, state, &err, msg, sizeof(msg), &len ); + ok( ret == SQL_NO_DATA, "got %d\n", ret ); + + ret = SQLError( env, con, stmt, state, &err, msg, sizeof(msg), &len ); + ok( ret == SQL_NO_DATA, "got %d\n", ret ); + ret = SQLFreeStmt( stmt, SQL_UNBIND ); ok( ret == SQL_SUCCESS, "got %d\n", ret );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 53 ++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index ee610bfc96d..fc1f42c6251 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -993,15 +993,18 @@ static SQLRETURN connect_win32_a( struct handle *handle, SQLCHAR *servername, SQ SQLSMALLINT len2, SQLCHAR *auth, SQLSMALLINT len3 ) { SQLRETURN ret = SQL_ERROR; - SQLWCHAR *servernameW, *usernameW = NULL, *authW = NULL; + SQLWCHAR *servernameW = NULL, *usernameW = NULL, *authW = NULL;
if (handle->win32_funcs->SQLConnect) return handle->win32_funcs->SQLConnect( handle->win32_handle, servername, len1, username, len2, auth, len3 );
- if (!(servernameW = strnAtoW( servername, len1 ))) return SQL_ERROR; - if (!(usernameW = strnAtoW( username, len2 ))) goto done; - if (!(authW = strnAtoW( auth, len3 ))) goto done; - ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, servernameW, len1, usernameW, len2, authW, len3 ); + if (handle->win32_funcs->SQLConnectW) + { + if (!(servernameW = strnAtoW( servername, len1 ))) return SQL_ERROR; + if (!(usernameW = strnAtoW( username, len2 ))) goto done; + if (!(authW = strnAtoW( auth, len3 ))) goto done; + ret = handle->win32_funcs->SQLConnectW( handle->win32_handle, servernameW, len1, usernameW, len2, authW, len3 ); + } done: free( servernameW ); free( usernameW ); @@ -1944,23 +1947,26 @@ static SQLRETURN get_diag_rec_win32_a( SQLSMALLINT handle_type, struct handle *h SQLSMALLINT *retlen ) { SQLRETURN ret = SQL_ERROR; - SQLWCHAR stateW[6], *msgW = NULL; + SQLWCHAR stateW[6], *msgW; SQLSMALLINT lenW;
if (handle->win32_funcs->SQLGetDiagRec) return handle->win32_funcs->SQLGetDiagRec( handle_type, handle->win32_handle, rec_num, state, native_err, msg, buflen, retlen );
- if (!(msgW = malloc( buflen * sizeof(WCHAR) ))) return SQL_ERROR; - ret = handle->win32_funcs->SQLGetDiagRecW( handle_type, handle->win32_handle, rec_num, stateW, native_err, - msgW, buflen, &lenW ); - if (SUCCESS( ret )) + if (handle->win32_funcs->SQLGetDiagRecW) { - int len = WideCharToMultiByte( CP_ACP, 0, msgW, -1, (char *)msg, buflen, NULL, NULL ); - if (retlen) *retlen = len - 1; - WideCharToMultiByte( CP_ACP, 0, stateW, -1, (char *)state, 6, NULL, NULL ); + if (!(msgW = malloc( buflen * sizeof(WCHAR) ))) return SQL_ERROR; + ret = handle->win32_funcs->SQLGetDiagRecW( handle_type, handle->win32_handle, rec_num, stateW, native_err, + msgW, buflen, &lenW ); + if (SUCCESS( ret )) + { + int len = WideCharToMultiByte( CP_ACP, 0, msgW, -1, (char *)msg, buflen, NULL, NULL ); + if (retlen) *retlen = len - 1; + WideCharToMultiByte( CP_ACP, 0, stateW, -1, (char *)state, 6, NULL, NULL ); + } + free( msgW ); } - free( msgW ); return ret; }
@@ -3627,21 +3633,24 @@ static SQLRETURN driver_connect_win32_a( struct handle *handle, SQLHWND window, SQLSMALLINT *outlen, SQLUSMALLINT completion ) { SQLRETURN ret = SQL_ERROR; - SQLWCHAR *in, *out = NULL; + SQLWCHAR *in = NULL, *out = NULL; SQLSMALLINT lenW;
if (handle->win32_funcs->SQLDriverConnect) return handle->win32_funcs->SQLDriverConnect( handle->win32_handle, window, in_conn_str, inlen, out_conn_str, buflen, outlen, completion );
- if (!(in = strnAtoW( in_conn_str, inlen ))) return SQL_ERROR; - if (!(out = malloc( buflen * sizeof(WCHAR) ))) goto done; - ret = handle->win32_funcs->SQLDriverConnectW( handle->win32_handle, window, in, inlen, out, buflen, &lenW, - completion ); - if (SUCCESS( ret )) + if (handle->win32_funcs->SQLDriverConnectW) { - int len = WideCharToMultiByte( CP_ACP, 0, out, -1, (char *)out_conn_str, buflen, NULL, NULL ); - if (outlen) *outlen = len - 1; + if (!(in = strnAtoW( in_conn_str, inlen ))) return SQL_ERROR; + if (!(out = malloc( buflen * sizeof(WCHAR) ))) goto done; + ret = handle->win32_funcs->SQLDriverConnectW( handle->win32_handle, window, in, inlen, out, buflen, &lenW, + completion ); + if (SUCCESS( ret )) + { + int len = WideCharToMultiByte( CP_ACP, 0, out, -1, (char *)out_conn_str, buflen, NULL, NULL ); + if (outlen) *outlen = len - 1; + } } done: free( in );
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 49 +++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index fc1f42c6251..653617a0f17 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -1387,6 +1387,29 @@ SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, S return ret; }
+static SQLRETURN exec_direct_unix_a( struct handle *handle, SQLCHAR *text, SQLINTEGER len ) +{ + struct SQLExecDirect_params params = { handle->unix_handle, text, len }; + return ODBC_CALL( SQLExecDirect, ¶ms ); +} + +static SQLRETURN exec_direct_win32_a( struct handle *handle, SQLCHAR *text, SQLINTEGER len ) +{ + SQLRETURN ret = SQL_ERROR; + SQLWCHAR *textW; + + if (handle->win32_funcs->SQLExecDirect) + return handle->win32_funcs->SQLExecDirect( handle->win32_handle, text, len ); + + if (handle->win32_funcs->SQLExecDirectW) + { + if (!(textW = strnAtoW( text, len ))) return SQL_ERROR; + ret = handle->win32_funcs->SQLExecDirectW( handle->win32_handle, textW, len ); + free( textW ); + } + return ret; +} + /************************************************************************* * SQLExecDirect [ODBC32.011] */ @@ -1402,12 +1425,11 @@ SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText,
if (handle->unix_handle) { - struct SQLExecDirect_params params = { handle->unix_handle, StatementText, TextLength }; - ret = ODBC_CALL( SQLExecDirect, ¶ms ); + ret = exec_direct_unix_a( handle, StatementText, TextLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLExecDirect( handle->win32_handle, StatementText, TextLength ); + ret = exec_direct_win32_a( handle, StatementText, TextLength ); }
TRACE("Returning %d\n", ret); @@ -4042,10 +4064,24 @@ SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle, return ret; }
+static SQLRETURN exec_direct_unix_w( struct handle *handle, SQLWCHAR *text, SQLINTEGER len ) +{ + struct SQLExecDirectW_params params = { handle->unix_handle, text, len }; + return ODBC_CALL( SQLExecDirectW, ¶ms ); +} + +static SQLRETURN exec_direct_win32_w( struct handle *handle, SQLWCHAR *text, SQLINTEGER len ) +{ + if (handle->win32_funcs->SQLExecDirectW) + return handle->win32_funcs->SQLExecDirectW( handle->win32_handle, text, len ); + if (handle->win32_funcs->SQLExecDirect) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLExecDirectW [ODBC32.111] */ -SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle, WCHAR *StatementText, SQLINTEGER TextLength) +SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle, SQLWCHAR *StatementText, SQLINTEGER TextLength) { struct handle *handle = StatementHandle; SQLRETURN ret = SQL_ERROR; @@ -4057,12 +4093,11 @@ SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle, WCHAR *StatementText,
if (handle->unix_handle) { - struct SQLExecDirectW_params params = { handle->unix_handle, StatementText, TextLength }; - ret = ODBC_CALL( SQLExecDirectW, ¶ms ); + ret = exec_direct_unix_w( handle, StatementText, TextLength ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLExecDirectW( handle->win32_handle, StatementText, TextLength ); + ret = exec_direct_win32_w( handle, StatementText, TextLength ); }
TRACE("Returning %d\n", ret);
From: Hans Leidekker hans@codeweavers.com
--- dlls/odbc32/proxyodbc.c | 95 +++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 14 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c index 653617a0f17..08fdba52439 100644 --- a/dlls/odbc32/proxyodbc.c +++ b/dlls/odbc32/proxyodbc.c @@ -3218,6 +3218,53 @@ SQLRETURN WINAPI SQLExtendedFetch(SQLHSTMT StatementHandle, SQLUSMALLINT FetchOr return ret; }
+static SQLRETURN foreign_keys_unix_a( struct handle *handle, SQLCHAR *pk_catalog, SQLSMALLINT len1, + SQLCHAR *pk_schema, SQLSMALLINT len2, SQLCHAR *pk_table, SQLSMALLINT len3, + SQLCHAR *fk_catalog, SQLSMALLINT len4, SQLCHAR *fk_schema, SQLSMALLINT len5, + SQLCHAR *fk_table, SQLSMALLINT len6 ) +{ + struct SQLForeignKeys_params params = { handle->unix_handle, pk_catalog, len1, pk_schema, len2, pk_table, len3, + fk_catalog, len4, fk_schema, len5, fk_table, len6 }; + return ODBC_CALL( SQLForeignKeys, ¶ms ); +} + +static SQLRETURN foreign_keys_win32_a( struct handle *handle, SQLCHAR *pk_catalog, SQLSMALLINT len1, + SQLCHAR *pk_schema, SQLSMALLINT len2, SQLCHAR *pk_table, SQLSMALLINT len3, + SQLCHAR *fk_catalog, SQLSMALLINT len4, SQLCHAR *fk_schema, SQLSMALLINT len5, + SQLCHAR *fk_table, SQLSMALLINT len6 ) +{ + SQLWCHAR *pk_catalogW = NULL, *pk_schemaW = NULL, *pk_tableW = NULL; + SQLWCHAR *fk_catalogW = NULL, *fk_schemaW = NULL, *fk_tableW = NULL; + SQLRETURN ret = SQL_ERROR; + + if (handle->win32_funcs->SQLForeignKeys) + { + return handle->win32_funcs->SQLForeignKeys( handle->win32_handle, pk_catalog, len1, pk_schema, len2, + pk_table, len3, fk_catalog, len4, fk_schema, len5, fk_table, + len6 ); + } + if (handle->win32_funcs->SQLForeignKeysW) + { + if (!(pk_catalogW = strnAtoW( pk_catalog, len1 ))) return SQL_ERROR; + if (!(pk_schemaW = strnAtoW( pk_schema, len2 ))) goto done; + if (!(pk_tableW = strnAtoW( pk_table, len3 ))) goto done; + if (!(fk_catalogW = strnAtoW( fk_catalog, len4 ))) goto done; + if (!(fk_schemaW = strnAtoW( fk_schema, len5 ))) goto done; + if (!(fk_tableW = strnAtoW( fk_table, len6 ))) goto done; + ret = handle->win32_funcs->SQLForeignKeysW( handle->win32_handle, pk_catalogW, len1, pk_schemaW, len2, + pk_tableW, len3, fk_catalogW, len4, fk_schemaW, len5, fk_tableW, + len6 ); + } +done: + free( pk_catalogW ); + free( pk_schemaW ); + free( pk_tableW ); + free( fk_catalogW ); + free( fk_schemaW ); + free( fk_tableW ); + return ret; +} + /************************************************************************* * SQLForeignKeys [ODBC32.060] */ @@ -3242,16 +3289,15 @@ SQLRETURN WINAPI SQLForeignKeys(SQLHSTMT StatementHandle, SQLCHAR *PkCatalogName
if (handle->unix_handle) { - struct SQLForeignKeys_params params = { handle->unix_handle, PkCatalogName, NameLength1, PkSchemaName, - NameLength2, PkTableName, NameLength3, FkCatalogName, NameLength4, - FkSchemaName, NameLength5, FkTableName, NameLength6 }; - ret = ODBC_CALL( SQLForeignKeys, ¶ms ); + ret = foreign_keys_unix_a( handle, PkCatalogName, NameLength1, PkSchemaName, NameLength2, PkTableName, + NameLength3, FkCatalogName, NameLength4, FkSchemaName, NameLength5, FkTableName, + NameLength6 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLForeignKeys( handle->win32_handle, PkCatalogName, NameLength1, PkSchemaName, - NameLength2, PkTableName, NameLength3, FkCatalogName, NameLength4, - FkSchemaName, NameLength5, FkTableName, NameLength6 ); + ret = foreign_keys_win32_a( handle, PkCatalogName, NameLength1, PkSchemaName, NameLength2, PkTableName, + NameLength3, FkCatalogName, NameLength4, FkSchemaName, NameLength5, FkTableName, + NameLength6 ); }
TRACE("Returning %d\n", ret); @@ -5083,6 +5129,28 @@ done: return ret; }
+static SQLRETURN foreign_keys_unix_w( struct handle *handle, SQLWCHAR *pk_catalog, SQLSMALLINT len1, + SQLWCHAR *pk_schema, SQLSMALLINT len2, SQLWCHAR *pk_table, SQLSMALLINT len3, + SQLWCHAR *fk_catalog, SQLSMALLINT len4, SQLWCHAR *fk_schema, SQLSMALLINT len5, + SQLWCHAR *fk_table, SQLSMALLINT len6 ) +{ + struct SQLForeignKeysW_params params = { handle->unix_handle, pk_catalog, len1, pk_schema, len2, pk_table, len3, + fk_catalog, len4, fk_schema, len5, fk_table, len6 }; + return ODBC_CALL( SQLForeignKeysW, ¶ms ); +} + +static SQLRETURN foreign_keys_win32_w( struct handle *handle, SQLWCHAR *pk_catalog, SQLSMALLINT len1, + SQLWCHAR *pk_schema, SQLSMALLINT len2, SQLWCHAR *pk_table, SQLSMALLINT len3, + SQLWCHAR *fk_catalog, SQLSMALLINT len4, SQLWCHAR *fk_schema, SQLSMALLINT len5, + SQLWCHAR *fk_table, SQLSMALLINT len6 ) +{ + if (handle->win32_funcs->SQLForeignKeysW) + return handle->win32_funcs->SQLForeignKeysW( handle->win32_handle, pk_catalog, len1, pk_schema, len2, pk_table, + len3, fk_catalog, len4, fk_schema, len5, fk_table, len6 ); + if (handle->win32_funcs->SQLForeignKeys) FIXME( "Unicode to ANSI conversion not handled\n" ); + return SQL_ERROR; +} + /************************************************************************* * SQLForeignKeysW [ODBC32.160] */ @@ -5107,16 +5175,15 @@ SQLRETURN WINAPI SQLForeignKeysW(SQLHSTMT StatementHandle, SQLWCHAR *PkCatalogNa
if (handle->unix_handle) { - struct SQLForeignKeysW_params params = { handle->unix_handle, PkCatalogName, NameLength1, PkSchemaName, - NameLength2, PkTableName, NameLength2, FkCatalogName, NameLength3, - FkSchemaName, NameLength5, FkTableName, NameLength6 }; - ret = ODBC_CALL( SQLForeignKeysW, ¶ms ); + ret = foreign_keys_unix_w( handle, PkCatalogName, NameLength1, PkSchemaName, NameLength2, PkTableName, + NameLength2, FkCatalogName, NameLength3, FkSchemaName, NameLength5, FkTableName, + NameLength6 ); } else if (handle->win32_handle) { - ret = handle->win32_funcs->SQLForeignKeysW( handle->win32_handle, PkCatalogName, NameLength1, PkSchemaName, - NameLength2, PkTableName, NameLength3, FkCatalogName, NameLength4, - FkSchemaName, NameLength5, FkTableName, NameLength6 ); + ret = foreign_keys_win32_w( handle, PkCatalogName, NameLength1, PkSchemaName, NameLength2, PkTableName, + NameLength3, FkCatalogName, NameLength4, FkSchemaName, NameLength5, FkTableName, + NameLength6 ); }
TRACE("Returning %d\n", ret);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147197
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000005E0104, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032