Index: driver/info.c =================================================================== --- driver/info.c (revision 962) +++ driver/info.c (working copy) @@ -367,6 +367,11 @@ /* break; will never reach */ case SQL_DATABASE_NAME: + if (reget_current_catalog(dbc)) + return set_dbc_error(dbc, "HY000", + "SQLGetInfo() failed to return current catalog.", + 0); + MYINFO_SET_STR(rgbInfoValue, cbInfoValueMax, pcbInfoValue, dbc->database); /* break; will never reach */ Index: test/my_info.c =================================================================== --- test/my_info.c (revision 962) +++ test/my_info.c (working copy) @@ -211,6 +211,55 @@ } +/* + Bug 3780, reading or setting ADODB.Connection.DefaultDatabase + is not supported +*/ +DECLARE_TEST(t_bug3780) +{ + HDBC hdbc1; + HSTMT hstmt1; + SQLCHAR conn[256], conn_out[256]; + SQLSMALLINT conn_out_len; + SQLCHAR rgbValue[MAX_NAME_LEN]; + SQLSMALLINT pcbInfo; + + /* The connection string must not include DATABASE. */ + sprintf((char *)conn, "DRIVER=%s;SERVER=localhost;" \ + "UID=%s;PASSWORD=%s", mydriver, myuid, mypwd); + if (mysock != NULL) + { + strcat((char *)conn, ";SOCKET="); + strcat((char *)conn, (char *)mysock); + } + + ok_env(henv, SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1)); + + ok_con(hdbc1, SQLDriverConnect(hdbc1, NULL, conn, sizeof(conn), conn_out, + sizeof(conn_out), &conn_out_len, + SQL_DRIVER_NOPROMPT)); + ok_con(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); + + ok_con(hdbc1, SQLGetInfo(hdbc1, SQL_DATABASE_NAME, rgbValue, + MAX_NAME_LEN, &pcbInfo)); + + is_num(pcbInfo, 4); + is_str(rgbValue, "null", pcbInfo); + + ok_con(hdbc1, SQLGetConnectAttr(hdbc1, SQL_ATTR_CURRENT_CATALOG, + rgbValue, MAX_NAME_LEN, &pcbInfo)); + + is_num(pcbInfo, 4); + is_str(rgbValue, "null", pcbInfo); + + ok_stmt(hstmt1, SQLFreeStmt(hstmt1, SQL_DROP)); + ok_con(hdbc1, SQLDisconnect(hdbc1)); + ok_con(hdbc1, SQLFreeHandle(SQL_HANDLE_DBC, hdbc1)); + + return OK; +} + + BEGIN_TESTS ADD_TEST(sqlgetinfo) ADD_TEST(t_gettypeinfo) @@ -220,6 +269,7 @@ ADD_TEST(t_bug28657) ADD_TEST(t_bug14639) ADD_TEST(t_bug31055) + ADD_TEST(t_bug3780) END_TESTS Index: test/my_unixodbc.c =================================================================== --- test/my_unixodbc.c (revision 962) +++ test/my_unixodbc.c (working copy) @@ -122,9 +122,9 @@ rc = SQLAllocConnect(henv1,&hdbc1); myenv(henv1,rc); - sprintf(conn_in,"DRIVER={MySQL ODBC 3.51 Driver};USER=%s;PASSWORD=%s;" + sprintf(conn_in,"DRIVER=%s;USER=%s;PASSWORD=%s;" "DATABASE=%s;SERVER=%s;OPTION=3;STMT=use mysql", - myuid, mypwd, mydb, myserver); + mydriver, myuid, mypwd, mydb, myserver); if (mysock != NULL) { strcat(conn_in, ";SOCKET="); Index: test/odbctap.h =================================================================== --- test/odbctap.h (revision 963) +++ test/odbctap.h (working copy) @@ -67,6 +67,7 @@ #define MAX_ROW_DATA_LEN 1000 #define MYSQL_NAME_LEN 64 +SQLCHAR *mydriver= (SQLCHAR *)"{MySQL ODBC 3.51 Driver}"; SQLCHAR *mydsn= (SQLCHAR *)"test"; SQLCHAR *myuid= (SQLCHAR *)"root"; SQLCHAR *mypwd= (SQLCHAR *)""; Index: test/my_cursor.c =================================================================== --- test/my_cursor.c (revision 963) +++ test/my_cursor.c (working copy) @@ -2613,9 +2613,9 @@ SQLUINTEGER row_count; /* Don't cache result option in the connection string */ - sprintf(conn, "DRIVER={MySQL ODBC 3.51 Driver};USER=%s;PASSWORD=%s;" + sprintf(conn, "DRIVER=%s;USER=%s;PASSWORD=%s;" "DATABASE=%s;SERVER=%s;OPTION=1048576", - myuid, mypwd, mydb, myserver); + mydriver, myuid, mypwd, mydb, myserver); if (mysock != NULL) { @@ -2706,9 +2706,9 @@ Result cache is enabled. Need to check that cached results are not broken */ - sprintf(conn,"DRIVER={MySQL ODBC 3.51 Driver};USER=%s;PASSWORD=%s;" + sprintf(conn,"DRIVER=%s;USER=%s;PASSWORD=%s;" "DATABASE=%s;SERVER=%s", - myuid, mypwd, mydb, myserver); + mydriver, myuid, mypwd, mydb, myserver); if (mysock != NULL) { Index: ChangeLog =================================================================== --- ChangeLog (revision 963) +++ ChangeLog (working copy) @@ -10,7 +10,9 @@ * Fixed thread synchronization bug in SQLAllocStmt()/SQLFreeStmt() functions. (Bug #32857) * Fixed SQLExtendedFetch() ignoring SQL_ROWSET_SIZE attribute if Don't cache - result option is set. (Bug #324020) + result option is set. (Bug #32420) + * SQLGetInfo() returns the "null" string as database name if no database + was selected. (Bug #3780) ----