diff --git a/plugins/auth/my_auth.c b/plugins/auth/my_auth.c index ea33e0cd..4e17ef7d 100644 --- a/plugins/auth/my_auth.c +++ b/plugins/auth/my_auth.c @@ -231,6 +231,10 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, #endif /* HAVE_TLS && !EMBEDDED_LIBRARY*/ if (mpvio->db) mysql->client_flag|= CLIENT_CONNECT_WITH_DB; + else + /* See CONC-490: If no database was specified, we need + to unset CLIENT_CONNECT_WITH_DB flag */ + mysql->client_flag&= ~CLIENT_CONNECT_WITH_DB; /* if server doesn't support SSL and verification of server certificate was set to mandatory, we need to return an error */ diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index 70d347ce..0da10cbe 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1892,7 +1892,22 @@ static int test_gtid(MYSQL *mysql) return OK; } +static int test_conc490(MYSQL *my __attribute__((unused))) +{ + MYSQL *mysql= mysql_init(NULL); + + if (!my_test_connect(mysql, hostname, username, + password, NULL, port, socketname, CLIENT_CONNECT_WITH_DB)) + { + diag("error: %s\n", mysql_error(mysql)); + return FAIL; + } + mysql_close(mysql); + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc490", test_conc490, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"test_gtid", test_gtid, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc496", test_conc496, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_default_auth", test_default_auth, TEST_CONNECTION_NONE, 0, NULL, NULL},