Merge commit '262f1d7e471bacca6b985ec3f2cd5cb76d6e2584' into 2.3

This commit is contained in:
Markus Mäkelä
2018-10-26 12:44:57 +03:00
5 changed files with 47 additions and 9 deletions

View File

@ -88,6 +88,9 @@ action=block
rules=/home/user/blacklist-rules.txt rules=/home/user/blacklist-rules.txt
``` ```
If a query is blocked, the filter will return an error to the client with the
error number 1141 and an SQL state of HY000.
#### `log_match` #### `log_match`
Log all queries that match a rule. For the `any` matching mode, the name of the Log all queries that match a rule. For the `any` matching mode, the name of the
@ -326,6 +329,9 @@ values are:
|use |USE operations | |use |USE operations |
|load |LOAD DATA operations | |load |LOAD DATA operations |
Multiple values can be combined using the pipe character `|` e.g.
` on_queries select|insert|update`.
### Applying rules to users ### Applying rules to users
The `users` directive defines the users to which the rule should be applied. The `users` directive defines the users to which the rule should be applied.

View File

@ -78,7 +78,7 @@ bool create_user(TestConnections& test, MYSQL* pMysql)
drop_user(test, pMysql, true); drop_user(test, pMysql, true);
test.try_query(pMysql, "CREATE USER '%s' IDENTIFIED by '%s'", ZUSER, ZPASSWORD); test.try_query(pMysql, "CREATE USER '%s'@'%%' IDENTIFIED by '%s'", ZUSER, ZPASSWORD);
test.try_query(pMysql, "GRANT SELECT, UPDATE ON %s TO '%s'@'%%'", ZTABLE, ZUSER); test.try_query(pMysql, "GRANT SELECT, UPDATE ON %s TO '%s'@'%%'", ZTABLE, ZUSER);
return test.global_result == 0; return test.global_result == 0;
@ -149,6 +149,8 @@ int main(int argc, char* argv[])
if (create_user(test, pMysql)) if (create_user(test, pMysql))
{ {
int rv = test.repl->connect(); int rv = test.repl->connect();
test.repl->sync_slaves();
test.expect(rv == 0, "Could not connect to MS."); test.expect(rv == 0, "Could not connect to MS.");
if (rv == 0) if (rv == 0)

View File

@ -59,5 +59,12 @@ int main(int argc, char* argv[])
test.maxscales->close_maxscale_connections(0); test.maxscales->close_maxscale_connections(0);
// MXS-2103
test.maxscales->connect();
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE TEMPORARY TABLE temp.dummy5 (dum INT);");
test.try_query(test.maxscales->conn_rwsplit[0], "INSERT INTO temp.dummy5 VALUES(1),(2);");
test.try_query(test.maxscales->conn_rwsplit[0], "SELECT * FROM temp.dummy5;");
test.maxscales->disconnect();
return test.global_result; return test.global_result;
} }

View File

@ -710,20 +710,36 @@ void QueryClassifier::check_create_tmp_table(GWBUF* querybuf, uint32_t type)
if (qc_query_is_type(type, QUERY_TYPE_CREATE_TMP_TABLE)) if (qc_query_is_type(type, QUERY_TYPE_CREATE_TMP_TABLE))
{ {
set_have_tmp_tables(true); set_have_tmp_tables(true);
char* tblname = qc_get_created_table_name(querybuf); int size = 0;
char** tblname = qc_get_table_names(querybuf, &size, true);
std::string table; std::string table;
if (tblname && *tblname && strchr(tblname, '.') == NULL) for (int i = 0; i < size; i++)
{ {
const char* db = qc_mysql_get_current_db(session()); if (tblname[i] && *tblname[i])
table += db; {
table += "."; table = tblname[i];
table += tblname;
if (strchr(tblname[i], '.') == NULL)
{
const char* db = qc_mysql_get_current_db(session());
table = db;
table += ".";
table += tblname[i];
}
break;
}
} }
MXS_INFO("Added temporary table %s", table.c_str());
/** Add the table to the set of temporary tables */ /** Add the table to the set of temporary tables */
add_tmp_table(table); add_tmp_table(table);
for (int i = 0; i < size; i++)
{
MXS_FREE(tblname[i]);
}
MXS_FREE(tblname); MXS_FREE(tblname);
} }
} }

View File

@ -987,14 +987,21 @@ bool RWSplitSession::handle_error_new_connection(DCB* backend_dcb, GWBUF* errmsg
route_stored_query(); route_stored_query();
} }
bool succp; bool succp = false;
/** /**
* Try to get replacement slave or at least the minimum * Try to get replacement slave or at least the minimum
* number of slave connections for router session. * number of slave connections for router session.
*/ */
if (m_recv_sescmd > 0 && m_config.disable_sescmd_history) if (m_recv_sescmd > 0 && m_config.disable_sescmd_history)
{ {
succp = m_router->have_enough_servers(); for (const auto& a : m_backends)
{
if (a->in_use())
{
succp = true;
break;
}
}
} }
else else
{ {