=== modified file 'test/my_basics.c' --- test/my_basics.c 2008-08-22 22:12:25 +0000 +++ test/my_basics.c 2008-08-28 12:10:21 +0000 @@ -909,6 +909,42 @@ } +/* + Bug #39085: MyODBC 5.1 fails to connect if connection string + parameters have preceding space +*/ +DECLARE_TEST(t_bug39085) +{ + SQLCHAR buff[512]; + SQLHENV henv1; + SQLHDBC hdbc1; + SQLHSTMT hstmt1; + SQLCHAR conn[MAX_NAME_LEN]; + + + /* Connect with the space and tab symbols before server parameter */ + sprintf((char *)conn, "DRIVER=%s;SERVER= %s;" \ + "UID=%s;PASSWORD=%s", mydriver, myserver, myuid, mypwd); + if (mysock != NULL) + { + strcat((char *)conn, ";SOCKET="); + strcat((char *)conn, (char *)mysock); + } + if (myport) + { + char pbuff[20]; + sprintf(pbuff, ";PORT=%d", myport); + strcat((char *)conn, pbuff); + } + + /* We only need to check that the connection has been established */ + is(mydrvconnect(&henv1, &hdbc1, &hstmt1, conn) == OK); + + free_basic_handles(&henv1, &hdbc1, &hstmt1); + return OK; +} + + BEGIN_TESTS ADD_TEST(my_basics) ADD_TEST(t_max_select) @@ -934,6 +970,7 @@ ADD_TEST(t_bug32727) ADD_TEST(t_bug28820) ADD_TEST(t_bug31959) + ADD_TEST(t_bug39085) END_TESTS === modified file 'util/installer.c' --- util/installer.c 2008-08-09 01:07:56 +0000 +++ util/installer.c 2008-08-29 11:03:42 +0000 @@ -790,6 +790,7 @@ if ((split= sqlwcharchr(attrs, (SQLWCHAR)'=')) == NULL) return 1; + split= sqlwcharignorespaces(split); memcpy(attribute, attrs, (split - attrs) * sizeof(SQLWCHAR)); attribute[split - attrs]= 0; split++; === modified file 'util/stringutil.c' --- util/stringutil.c 2008-04-15 08:03:35 +0000 +++ util/stringutil.c 2008-08-29 11:02:55 +0000 @@ -647,3 +647,17 @@ return dest; } + + +/* + * Ignore space symbols SQLWCHAR string. + * + * @return Position of char next after the space. + */ +SQLWCHAR *sqlwcharignorespaces(const SQLWCHAR *wstr) +{ + while(((*(wstr + 1) == (SQLWCHAR)' ') || + (*(wstr + 1) == (SQLWCHAR)'\t')) && + *wstr++); + return wstr; +}