Modified:
branches/guffert/ChangeLog
branches/guffert/driver/connect.c
branches/guffert/setupgui/utils.c
branches/guffert/setupgui/windows/odbcdialogparams.cpp
branches/guffert/util/installer.c
Log:
DSN-less connection prompting cannot lookup driver entry (Bug #37254)
Modified: branches/guffert/ChangeLog
===================================================================
--- branches/guffert/ChangeLog 2008-07-30 13:55:04 UTC (rev 1132)
+++ branches/guffert/ChangeLog 2008-07-30 16:33:26 UTC (rev 1133)
@@ -15,6 +15,8 @@
(Bug #26950)
* SQL_TYPE_TIMESTAMP and SQL_TYPE_TIME parameters were incorrectly
included when parameters were expanded. (Bug #37342)
+ * DSN-less connection prompting cannot lookup driver entry
+ (Bug #37254)
Includes changes from Connector/ODBC 3.51.26.
Modified: branches/guffert/driver/connect.c
===================================================================
--- branches/guffert/driver/connect.c 2008-07-30 13:55:04 UTC (rev 1132)
+++ branches/guffert/driver/connect.c 2008-07-30 16:33:26 UTC (rev 1133)
@@ -602,14 +602,13 @@
goto error;
}
- /*
- At this point we should have a driver name (friendly name) either
- loaded from DSN or provided in connection string. So lets determine
- the setup library file name (better to not assume name). We read from
- ODBC system info. This allows someone configure for a custom setup
- interface.
- */
- sqlwcharncpy(pDriver->lib, ds->driver, ODBCDRIVER_STRLEN);
+ /* if given a named DSN, we will have the path in the DRIVER field */
+ if (ds->name)
+ sqlwcharncpy(pDriver->lib, ds->driver, ODBCDRIVER_STRLEN);
+ /* otherwise, it's the driver name */
+ else
+ sqlwcharncpy(pDriver->name, ds->driver, ODBCDRIVER_STRLEN);
+
if (driver_lookup(pDriver))
{
char sz[1024];
Modified: branches/guffert/setupgui/utils.c
===================================================================
--- branches/guffert/setupgui/utils.c 2008-07-30 13:55:04 UTC (rev 1132)
+++ branches/guffert/setupgui/utils.c 2008-07-30 16:33:26 UTC (rev 1133)
@@ -83,7 +83,6 @@
{
SQLRETURN nReturn;
SQLWCHAR stringConnectIn[1024];
- Driver *driver;
size_t inlen= 1024;
assert(params->driver && *params->driver);
@@ -98,20 +97,6 @@
}
inlen-= sqlwcharlen(stringConnectIn);
- /* Add driver name (not file) to connect string */
- driver= driver_new();
- memcpy(driver->lib, params->driver,
- (sqlwcharlen(params->driver) + 1) * sizeof(SQLWCHAR));
- if (driver_lookup_name(driver))
- {
- driver_delete(driver);
- /* TODO error message */
- return SQL_ERROR;
- }
- sqlwcharncat2(stringConnectIn, W_DRIVER_PARAM, &inlen);
- sqlwcharncat2(stringConnectIn, driver->name, &inlen);
- driver_delete(driver);
-
if (hDBC == SQL_NULL_HDBC)
{
nReturn= SQLAllocHandle(SQL_HANDLE_ENV, NULL, hEnv);
Modified: branches/guffert/setupgui/windows/odbcdialogparams.cpp
===================================================================
--- branches/guffert/setupgui/windows/odbcdialogparams.cpp 2008-07-30 13:55:04 UTC (rev
1132)
+++ branches/guffert/setupgui/windows/odbcdialogparams.cpp 2008-07-30 16:33:26 UTC (rev
1133)
@@ -645,6 +645,13 @@
{
EnableWindow(GetDlgItem(hwnd, IDC_EDIT_name), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_EDIT_description), FALSE);
+ /* if prompting without DSN, don't disable OK button */
+ if (!pParams->name)
+ {
+ Button_Enable(GetDlgItem(hwnd,IDOK), 1);
+ Button_Enable(GetDlgItem(hwnd,IDC_BUTTON_TEST), 1);
+ RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE);
+ }
}
BOOL b = DoCreateDialogTooltip();
@@ -687,6 +694,27 @@
pCaption= L"MySQL Connector/ODBC Data Source Configuration";
g_isPrompt= isPrompt;
+ /*
+ If prompting (with a DSN name), or not prompting (add/edit DSN),
+ we translate the lib path to the actual driver name.
+ */
+ if (params->name || !isPrompt)
+ {
+ Driver *driver= driver_new();
+ memcpy(driver->lib, params->driver,
+ (sqlwcharlen(params->driver) + 1) * sizeof(SQLWCHAR));
+ if (driver_lookup_name(driver))
+ {
+ wchar_t msg[256];
+ swprintf(msg, L"Failure to lookup driver entry at path '%ls'",
+ driver->lib);
+ MessageBox(ParentWnd, msg, L"Cannot find driver entry", MB_OK);
+ driver_delete(driver);
+ return 0;
+ }
+ ds_set_strattr(¶ms->driver, driver->name);
+ driver_delete(driver);
+ }
DialogBox(ghInstance, MAKEINTRESOURCE(IDD_DIALOG1), ParentWnd,
(DLGPROC)FormMain_DlgProc);
Modified: branches/guffert/util/installer.c
===================================================================
--- branches/guffert/util/installer.c 2008-07-30 13:55:04 UTC (rev 1132)
+++ branches/guffert/util/installer.c 2008-07-30 16:33:26 UTC (rev 1133)
@@ -807,7 +807,8 @@
attrs+= sqlwcharncat2(attrs, *strval, &attrslen);
APPEND_SQLWCHAR(attrs, attrslen, delim);
}
- else if (intval)
+ /* only write out int values if they're non-zero */
+ else if (intval && *intval)
{
attrs+= sqlwcharncat2(attrs, dsnparams[i], &attrslen);
APPEND_SQLWCHAR(attrs, attrslen, '=');
@@ -931,11 +932,11 @@
RESTORE_MODE();
- /* Get the actual driver name (not just file name) */
+ /* Get the actual driver info (not just name) */
driver= driver_new();
- memcpy(driver->lib, ds->driver,
+ memcpy(driver->name, ds->driver,
(sqlwcharlen(ds->driver) + 1) * sizeof(SQLWCHAR));
- if (driver_lookup_name(driver))
+ if (driver_lookup(driver))
{
SQLPostInstallerErrorW(ODBC_ERROR_INVALID_KEYWORD_VALUE,
W_CANNOT_FIND_DRIVER);
@@ -949,7 +950,7 @@
RESTORE_MODE();
/* write all fields (util method takes care of skipping blank fields) */
- if (ds_add_strprop(ds->name, W_DRIVER , ds->driver )) goto error;
+ if (ds_add_strprop(ds->name, W_DRIVER , driver->lib )) goto error;
if (ds_add_strprop(ds->name, W_DESCRIPTION, ds->description)) goto error;
if (ds_add_strprop(ds->name, W_SERVER , ds->server )) goto error;
if (ds_add_strprop(ds->name, W_UID , ds->uid )) goto error;
| Thread |
|---|
| • Connector/ODBC 3.51 commit: r1133 - in branches/guffert: . driver setupgui setupgui/windows util | jbalint | 30 Jul |