msdasql: Implement ICommandPrepare Prepare.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1636530c81
commit
7491a7f13f
|
@ -43,7 +43,7 @@ DEFINE_GUID(DBPROPSET_DBINIT, 0xc8b522bc, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0
|
||||||
|
|
||||||
DEFINE_GUID(DBGUID_DEFAULT, 0xc8b521fb, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
|
DEFINE_GUID(DBGUID_DEFAULT, 0xc8b521fb, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
|
||||||
|
|
||||||
static void dump_sql_diag_records(SQLSMALLINT type, SQLHANDLE handle)
|
void dump_sql_diag_records(SQLSMALLINT type, SQLHANDLE handle)
|
||||||
{
|
{
|
||||||
SQLCHAR state[6], msg[SQL_MAX_MESSAGE_LENGTH];
|
SQLCHAR state[6], msg[SQL_MAX_MESSAGE_LENGTH];
|
||||||
SQLINTEGER native;
|
SQLINTEGER native;
|
||||||
|
@ -611,7 +611,7 @@ static HRESULT WINAPI dbsess_CreateSession(IDBCreateSession *iface, IUnknown *ou
|
||||||
if (outer)
|
if (outer)
|
||||||
FIXME("outer currently not supported.\n");
|
FIXME("outer currently not supported.\n");
|
||||||
|
|
||||||
hr = create_db_session(riid, &provider->MSDASQL_iface, (void**)session);
|
hr = create_db_session(riid, &provider->MSDASQL_iface, provider->hdbc, (void**)session);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,5 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HRESULT create_db_session(REFIID riid, IUnknown *datasource, void **unk) DECLSPEC_HIDDEN;
|
HRESULT create_db_session(REFIID riid, IUnknown *datasource, HDBC hdbc, void **unk) DECLSPEC_HIDDEN;
|
||||||
|
void dump_sql_diag_records(SQLSMALLINT type, SQLHANDLE handle) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "msdasql.h"
|
#include "msdasql.h"
|
||||||
#include "oledberr.h"
|
#include "oledberr.h"
|
||||||
|
#include "sqlucode.h"
|
||||||
|
|
||||||
#include "msdasql_private.h"
|
#include "msdasql_private.h"
|
||||||
|
|
||||||
|
@ -45,6 +46,8 @@ struct msdasql_session
|
||||||
LONG refs;
|
LONG refs;
|
||||||
|
|
||||||
IUnknown *datasource;
|
IUnknown *datasource;
|
||||||
|
|
||||||
|
HDBC hdbc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
|
static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
|
||||||
|
@ -305,6 +308,8 @@ struct command
|
||||||
LONG refs;
|
LONG refs;
|
||||||
WCHAR *query;
|
WCHAR *query;
|
||||||
IUnknown *session;
|
IUnknown *session;
|
||||||
|
HDBC hdbc;
|
||||||
|
SQLHSTMT hstmt;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct command *impl_from_ICommandText( ICommandText *iface )
|
static inline struct command *impl_from_ICommandText( ICommandText *iface )
|
||||||
|
@ -424,6 +429,10 @@ static ULONG WINAPI command_Release(ICommandText *iface)
|
||||||
TRACE( "destroying %p\n", command );
|
TRACE( "destroying %p\n", command );
|
||||||
if (command->session)
|
if (command->session)
|
||||||
IUnknown_Release(command->session);
|
IUnknown_Release(command->session);
|
||||||
|
|
||||||
|
if (command->hstmt)
|
||||||
|
SQLFreeHandle(SQL_HANDLE_STMT, command->hstmt);
|
||||||
|
|
||||||
heap_free( command->query );
|
heap_free( command->query );
|
||||||
heap_free( command );
|
heap_free( command );
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1060,24 @@ static ULONG WINAPI commandprepare_Release(ICommandPrepare *iface)
|
||||||
static HRESULT WINAPI commandprepare_Prepare(ICommandPrepare *iface, ULONG runs)
|
static HRESULT WINAPI commandprepare_Prepare(ICommandPrepare *iface, ULONG runs)
|
||||||
{
|
{
|
||||||
struct command *command = impl_from_ICommandPrepare( iface );
|
struct command *command = impl_from_ICommandPrepare( iface );
|
||||||
|
RETCODE ret;
|
||||||
|
|
||||||
TRACE("%p, %u\n", command, runs);
|
TRACE("%p, %u\n", command, runs);
|
||||||
|
|
||||||
|
if (!command->query)
|
||||||
|
return DB_E_NOCOMMAND;
|
||||||
|
|
||||||
|
if (command->hstmt)
|
||||||
|
SQLFreeHandle(SQL_HANDLE_STMT, command->hstmt);
|
||||||
|
|
||||||
|
SQLAllocHandle(SQL_HANDLE_STMT, command->hdbc, &command->hstmt);
|
||||||
|
|
||||||
|
ret = SQLPrepareW(command->hstmt, command->query, SQL_NTS);
|
||||||
|
if (ret != SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
dump_sql_diag_records(SQL_HANDLE_STMT, command->hstmt);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,6 +1173,8 @@ static HRESULT WINAPI createcommand_CreateCommand(IDBCreateCommand *iface, IUnkn
|
||||||
command->ICommandWithParameters_iface.lpVtbl = &command_with_params_vtbl;
|
command->ICommandWithParameters_iface.lpVtbl = &command_with_params_vtbl;
|
||||||
command->refs = 1;
|
command->refs = 1;
|
||||||
command->query = NULL;
|
command->query = NULL;
|
||||||
|
command->hdbc = session->hdbc;
|
||||||
|
command->hstmt = NULL;
|
||||||
|
|
||||||
IUnknown_QueryInterface(&session->session_iface, &IID_IUnknown, (void**)&command->session);
|
IUnknown_QueryInterface(&session->session_iface, &IID_IUnknown, (void**)&command->session);
|
||||||
|
|
||||||
|
@ -1163,7 +1191,7 @@ static const IDBCreateCommandVtbl createcommandVtbl =
|
||||||
createcommand_CreateCommand
|
createcommand_CreateCommand
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT create_db_session(REFIID riid, IUnknown *datasource, void **unk)
|
HRESULT create_db_session(REFIID riid, IUnknown *datasource, HDBC hdbc, void **unk)
|
||||||
{
|
{
|
||||||
struct msdasql_session *session;
|
struct msdasql_session *session;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -1179,6 +1207,7 @@ HRESULT create_db_session(REFIID riid, IUnknown *datasource, void **unk)
|
||||||
session->IDBCreateCommand_iface.lpVtbl = &createcommandVtbl;
|
session->IDBCreateCommand_iface.lpVtbl = &createcommandVtbl;
|
||||||
IUnknown_QueryInterface(datasource, &IID_IUnknown, (void**)&session->datasource);
|
IUnknown_QueryInterface(datasource, &IID_IUnknown, (void**)&session->datasource);
|
||||||
session->refs = 1;
|
session->refs = 1;
|
||||||
|
session->hdbc = hdbc;
|
||||||
|
|
||||||
hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
|
hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
|
||||||
IUnknown_Release(&session->session_iface);
|
IUnknown_Release(&session->session_iface);
|
||||||
|
|
|
@ -354,6 +354,7 @@ static void test_rowset_interfaces(IRowset *rowset, ICommandText *commandtext)
|
||||||
static void test_command_rowset(IUnknown *cmd)
|
static void test_command_rowset(IUnknown *cmd)
|
||||||
{
|
{
|
||||||
ICommandText *command_text;
|
ICommandText *command_text;
|
||||||
|
ICommandPrepare *commandprepare;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IUnknown *unk = NULL;
|
IUnknown *unk = NULL;
|
||||||
IRowset *rowset;
|
IRowset *rowset;
|
||||||
|
@ -362,9 +363,22 @@ static void test_command_rowset(IUnknown *cmd)
|
||||||
hr = IUnknown_QueryInterface(cmd, &IID_ICommandText, (void**)&command_text);
|
hr = IUnknown_QueryInterface(cmd, &IID_ICommandText, (void**)&command_text);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = IUnknown_QueryInterface(cmd, &IID_ICommandPrepare, (void**)&commandprepare);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, NULL);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = ICommandPrepare_Prepare(commandprepare, 1);
|
||||||
|
ok(hr == DB_E_NOCOMMAND, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"CREATE TABLE testing (col1 INT, col2 SHORT)");
|
hr = ICommandText_SetCommandText(command_text, &DBGUID_DEFAULT, L"CREATE TABLE testing (col1 INT, col2 SHORT)");
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = ICommandPrepare_Prepare(commandprepare, 1);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ICommandPrepare_Release(commandprepare);
|
||||||
|
|
||||||
affected = 9999;
|
affected = 9999;
|
||||||
hr = ICommandText_Execute(command_text, NULL, &IID_IRowset, NULL, &affected, &unk);
|
hr = ICommandText_Execute(command_text, NULL, &IID_IRowset, NULL, &affected, &unk);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
Loading…
Reference in New Issue