Module: wine Branch: master Commit: f0bad1ec37a135d41ad2a31f8e245166447d1dd7 URL: https://gitlab.winehq.org/wine/wine/-/commit/f0bad1ec37a135d41ad2a31f8e24516...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Mon Nov 20 18:04:21 2023 +0800
msdasql: Return all initialization properties if no property ID is specified in dbprops_GetProperties().
---
dlls/msdasql/msdasql_main.c | 34 +++++++++++++++++++++++++++++++--- dlls/msdasql/tests/provider.c | 4 ---- 2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c index 7ec35678b6f..34342295651 100644 --- a/dlls/msdasql/msdasql_main.c +++ b/dlls/msdasql/msdasql_main.c @@ -357,18 +357,19 @@ static HRESULT WINAPI dbprops_GetProperties(IDBProperties *iface, ULONG cPropert struct msdasql *provider = impl_from_IDBProperties(iface); int i, j, k; DBPROPSET *propset; + BOOL no_prop_id;
TRACE("(%p)->(%ld %p %p %p)\n", provider, cPropertyIDSets, rgPropertyIDSets, pcPropertySets, prgPropertySets);
*pcPropertySets = 1;
- if (cPropertyIDSets != 1) + if (cPropertyIDSets > 1) { - FIXME("Currently only 1 property set supported.\n"); + FIXME("Currently only 0 or 1 property set are supported.\n"); cPropertyIDSets = 1; }
- propset = CoTaskMemAlloc(cPropertyIDSets * sizeof(DBPROPSET)); + propset = CoTaskMemAlloc(max(cPropertyIDSets, 1) * sizeof(DBPROPSET));
if (IsEqualGUID(&rgPropertyIDSets[0].guidPropertySet, &DBPROPSET_DATASOURCEINFO)) { @@ -391,6 +392,33 @@ static HRESULT WINAPI dbprops_GetProperties(IDBProperties *iface, ULONG cPropert
propset->guidPropertySet = DBPROPSET_DBINIT;
+ no_prop_id = TRUE; + for (i = 0; i < cPropertyIDSets; i++) + { + if (rgPropertyIDSets[i].cPropertyIDs) + { + no_prop_id = FALSE; + break; + } + } + + /* If no property ID is specified then return all currently set properties */ + if (no_prop_id) + { + propset->cProperties = ARRAY_SIZE(provider->properties); + propset->rgProperties = CoTaskMemAlloc(propset->cProperties * sizeof(DBPROP)); + for(i = 0; i < ARRAY_SIZE(provider->properties); i++) + { + propset->rgProperties[i].dwPropertyID = provider->properties[i].id; + V_VT(&propset->rgProperties[i].vValue) = VT_EMPTY; + VariantCopy(&propset->rgProperties[i].vValue, &provider->properties[i].value); + } + + *prgPropertySets = propset; + return S_OK; + } + + /* Return property info for properties in the specified property ID sets */ for (i=0; i < cPropertyIDSets; i++) { TRACE("Property id %d (count %ld, set %s)\n", i, rgPropertyIDSets[i].cPropertyIDs, diff --git a/dlls/msdasql/tests/provider.c b/dlls/msdasql/tests/provider.c index 10517484c83..706d5a13ef9 100644 --- a/dlls/msdasql/tests/provider.c +++ b/dlls/msdasql/tests/provider.c @@ -201,10 +201,8 @@ static void test_Properties(void) /* Test when cPropertyIDSets is zero, all initialization properties should be returned */ hr = IDBProperties_GetProperties(props, 0, &propidlist, &propcnt, &propset); ok(hr == S_OK, "got 0x%08lx\n", hr); - todo_wine ok(propset->cProperties == ARRAY_SIZE(properties), "got %lu\n", propset->cProperties); for (i = 0; i < propset->cProperties; i++) - todo_wine_if(i > 0) ok(propset->rgProperties[i].dwPropertyID == properties[i], "%ld %ld, got %ld\n", i, properties[i], propset->rgProperties[i].dwPropertyID); free_dbpropset(propcnt, propset); @@ -217,9 +215,7 @@ static void test_Properties(void)
hr = IDBProperties_GetProperties(props, 1, &propidlist, &propcnt, &propset); ok(hr == S_OK, "got 0x%08lx\n", hr); - todo_wine ok(propset->cProperties == ARRAY_SIZE(properties), "got %lu\n", propset->cProperties); - todo_wine for (i = 0; i < propset->cProperties; i++) ok(propset->rgProperties[i].dwPropertyID == properties[i], "%ld %ld, got %ld\n", i, properties[i], propset->rgProperties[i].dwPropertyID);