Michael,
attached a patch to make myodbc use the odbc.ini entries.
One of them is for the actual iodbc (adding SQLGetPrivateProfileString)
while the other contains the necessary connect.c adjustments for myodbc.
Lars
> Hi!
>
> >>>>> "Lars" == Lars Doelle <lars.doelle@stripped> writes:
>
> Lars> Hi,
> Lars> as you might know, the iodbc dm is now maintained for quite a while.
> Lars> So it does not make sense to distribute a private version of iodbc anymore.
>
> Sounds good!
>
> Lars> Though myodbc does run with the "officical" version, i found that myodbc
> Lars> has a general flaw, it does not make use of the driver configuration.
>
> Lars> So, SQLConnect is plain broken on unix.
>
> Lars> The issue is, that no SQLGetPrivateProfileString is provided by neither
> Lars> myodbc's special iodbc edition nor by the current version of the iodbc.
>
> Lars> I tried to contact Giovanni earlier to hash the issue out, but it failed,
> so
> Lars> perhaps this list is a better address.
>
> Lars> Another flaw i found with myodbc is that it requires the mysql sources
> Lars> to be installed (for some headers). Because i feel otherwise comfortable
> Lars> with the binary distribution i use and it also includes all the headers
> that
> Lars> mysql installs regularly, i wonder if this could not be fixed also.
>
> I got a mail about this a couple of days ago and this should be fixed
> in the next MySQL version (3.22.21).
>
> Lars> Regards, Lars
>
> Regards,
> Monty
>
> ---------------------------------------------------------------------
> To request this thread, e-mail myodbc-thread76@stripped
> To unsubscribe, e-mail the address shown in the
> List-Unsubscribe header of this message.
> For additional commands, e-mail: myodbc-help@stripped
Index: misc.c
===================================================================
RCS file: /source/CVSROOT/iODBC/misc.c,v
retrieving revision 1.5
diff -u -r1.5 misc.c
--- misc.c 1999/03/17 09:01:12 1.5
+++ misc.c 1999/03/22 11:28:01
@@ -415,3 +415,24 @@
return NULL;
}
+
+int
+SQLGetPrivateProfileString (
+ char *lpszSection,
+ char *lpszEntry,
+ char *lpszDefault,
+ char *RetBuffer,
+ int cbRetBuffer,
+ char *lpzFilename)
+{
+ char *value;
+
+ value = _iodbcdm_getkeyvalbydsn (
+ lpszSection, SQL_NTS,
+ lpszEntry, RetBuffer, cbRetBuffer);
+
+ if (value == NULL)
+ strncpy (RetBuffer, lpszDefault, cbRetBuffer);
+
+ return strlen (RetBuffer);
+}
--- connect.c.orig Tue Mar 9 20:07:32 1999
+++ connect.c Sat Mar 27 17:22:08 1999
@@ -179,7 +179,7 @@
DBUG_RETURN(set_error(hdbc,"08002","Connection in use",0));
}
dbc->sqlstate[0]=0;
-#ifndef _UNIX_
+
SQLGetPrivateProfileString(fix_str(dsn,szDSN,cbDSN),"server",
"localhost", host, sizeof(host),"ODBC.INI");
SQLGetPrivateProfileString(dsn,"database",
@@ -192,7 +192,8 @@
flag_nr=(ulong) atol(flag);
SQLGetPrivateProfileString(dsn,"stmt",
"0", init_stmt, sizeof(init_stmt),"ODBC.INI");
-#else
+
+/* OBSOLETE
strmov(database,szDSN);
{
char *cp;
@@ -200,7 +201,7 @@
}
flag_nr=0;
init_stmt[0]=0;
-#endif /* IS UNIX */
+*/
client_flag=get_client_flag(&dbc->mysql,flag_nr,(uint) dbc->login_timeout,
init_stmt);
@@ -404,6 +405,9 @@
int i;
uint client_flag=0;
+ char host[64],user[64],passwd[64],dsn[NAME_LEN+1],database[NAME_LEN+1],
+ port[10],flag[10],socket[256],init_stmt[256],option[64];
+
BOOL fPrompt = FALSE;
DBC FAR *dbc=(DBC FAR*) hdbc;
DBUG_ENTER("SQLDriverConnect");
@@ -529,6 +533,41 @@
}
}
+
+ if (KEY_DSN)
+ {
+ SQLGetPrivateProfileString(KEY_DSN,"server",
+ "localhost", host, sizeof(host),"ODBC.INI");
+ if (!KEY_SERVER) KEY_SERVER = (char*) my_strdup(host, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"database",
+ dsn, database, sizeof(database),"ODBC.INI");
+ if (!KEY_DB) KEY_DB = (char*) my_strdup(database, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"option",
+ "0", option, sizeof(option),"ODBC.INI");
+ if (!KEY_OPTION) KEY_OPTION = (char*) my_strdup(option, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"port",
+ "3306", port, sizeof(port),"ODBC.INI");
+ if (!KEY_PORT) KEY_PORT = (char*) my_strdup(port, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"stmt",
+ "", init_stmt, sizeof(init_stmt),"ODBC.INI");
+ if (!KEY_STMT) KEY_STMT = (char*) my_strdup(init_stmt, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"user",
+ "dummy", user, sizeof(user),"ODBC.INI");
+ if (!KEY_USER) KEY_USER = (char*) my_strdup(user, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"password",
+ "", passwd, sizeof(passwd),"ODBC.INI");
+ if (!KEY_PASSWORD) KEY_PASSWORD = (char*) my_strdup(passwd, MYF(MY_WME));
+
+ SQLGetPrivateProfileString(KEY_DSN,"socket",
+ "", socket, sizeof(socket),"ODBC.INI");
+ if (!KEY_SOCKET) KEY_SOCKET = (char*) my_strdup(socket, MYF(MY_WME));
+ }
if (!KEY_DB && KEY_DSN)
KEY_DB = (char*) my_strdup(KEY_DSN, MYF(MY_WME));