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={MySQL ODBC 3.51 Driver};SERVER=localhost;" \ + "UID=%s;PASSWORD=%s", 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: 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) ----