diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 06620f9b8..22b142605 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -476,6 +476,10 @@ add_test_executable(mxs1045.cpp mxs1045 mxs1045 LABELS maxscale REPL_BACKEND) # https://jira.mariadb.org/browse/MXS-1123 add_test_executable(mxs1123.cpp mxs1123 mxs1123 LABELS maxscale REPL_BACKEND) +# MXS-1319: Maxscale selecting extra whitespace while loading users +# https://jira.mariadb.org/browse/MXS-1319 +add_test_executable(mxs1319.cpp mxs1319 replication LABELS MySQLAuth REPL_BACKEND) + # 'namedserverfilter' test add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND) diff --git a/maxscale-system-test/mxs1319.cpp b/maxscale-system-test/mxs1319.cpp new file mode 100644 index 000000000..04d3aeda5 --- /dev/null +++ b/maxscale-system-test/mxs1319.cpp @@ -0,0 +1,23 @@ +/** + * Check that SQL_MODE='PAD_CHAR_TO_FULL_LENGTH' doesn't break authentication + */ + +#include "testconnections.h" + +int main(int argc, char *argv[]) +{ + TestConnections test(argc, argv); + + test.tprintf("Changing SQL_MODE to PAD_CHAR_TO_FULL_LENGTH and restarting MaxScale"); + test.repl->connect(); + test.repl->execute_query_all_nodes("SET GLOBAL SQL_MODE='PAD_CHAR_TO_FULL_LENGTH'"); + test.restart_maxscale(); + + test.tprintf("Connecting to MaxScale and executing a query"); + test.connect_maxscale(); + test.try_query(test.conn_rwsplit, "SELECT 1"); + test.close_maxscale_connections(); + + test.repl->execute_query_all_nodes("SET GLOBAL SQL_MODE=DEFAULT"); + return test.global_result; +} diff --git a/server/core/mysql_utils.c b/server/core/mysql_utils.c index 4fb8deb33..05fb5d516 100644 --- a/server/core/mysql_utils.c +++ b/server/core/mysql_utils.c @@ -174,6 +174,11 @@ MYSQL *mxs_mysql_real_connect(MYSQL *con, SERVER *server, const char *user, cons MY_CHARSET_INFO cs_info; mysql_get_character_set_info(mysql, &cs_info); server->charset = cs_info.number; + + if (mysql_query(mysql, "SET SQL_MODE=''")) + { + MXS_ERROR("Failed to change SQL_MODE: %s", mysql_error(mysql)); + } } return mysql;