Disallow all prepared statement commands with dbfwfilter
All binary protocol prepared statements should be rejected by the dbfwfilter in 2.0 as they aren't supported.
This commit is contained in:
parent
c3ffc0ba9c
commit
8d5c6ca00f
@ -21,6 +21,7 @@ int main(int argc, char** argv)
|
||||
test.connect_maxscale();
|
||||
execute_query_silent(test.conn_rwsplit, "DROP TABLE test.t1");
|
||||
|
||||
test.set_timeout(60);
|
||||
test.try_query(test.conn_rwsplit, "CREATE TABLE test.t1(a INT, b INT, c INT)");
|
||||
test.try_query(test.conn_rwsplit, "INSERT INTO test.t1 VALUES (1, 1, 1)");
|
||||
|
||||
@ -34,6 +35,7 @@ int main(int argc, char** argv)
|
||||
test.add_result(execute_query(test.conn_rwsplit, "EXECUTE my_ps2") == 0,
|
||||
"Text protocol execution should fail");
|
||||
|
||||
test.set_timeout(60);
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.conn_rwsplit);
|
||||
const char *query = "SELECT a, b FROM test.t1";
|
||||
|
||||
@ -47,7 +49,8 @@ int main(int argc, char** argv)
|
||||
test.add_result(!mysql_stmt_prepare(stmt, query, strlen(query)), "Binary protocol preparation should fail");
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
test.try_query(test.conn_rwsplit, "DROP TABLE test.t1");
|
||||
test.repl->connect();
|
||||
test.try_query(test.repl->nodes[0], "DROP TABLE test.t1");
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -2191,6 +2191,23 @@ static bool command_is_mandatory(const GWBUF *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
static bool command_is_prepare(uint8_t command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case MYSQL_COM_STMT_PREPARE:
|
||||
case MYSQL_COM_STMT_EXECUTE:
|
||||
case MYSQL_COM_STMT_SEND_LONG_DATA:
|
||||
case MYSQL_COM_STMT_CLOSE:
|
||||
case MYSQL_COM_STMT_RESET:
|
||||
case MYSQL_COM_STMT_FETCH:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The routeQuery entry point. This is passed the query buffer
|
||||
* to which the filter should be applied. Once processed the
|
||||
@ -2209,8 +2226,9 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
DCB *dcb = my_session->session->client_dcb;
|
||||
int rval = 0;
|
||||
ss_dassert(dcb && dcb->session);
|
||||
|
||||
uint32_t type = 0;
|
||||
uint8_t command = 0;
|
||||
gwbuf_copy_data(queue, MYSQL_HEADER_LEN, 1, &command);
|
||||
|
||||
if (modutil_is_SQL(queue) || modutil_is_SQL_prepare(queue))
|
||||
{
|
||||
@ -2228,7 +2246,7 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
}
|
||||
else if (QUERY_IS_TYPE(type, QUERY_TYPE_PREPARE_STMT) ||
|
||||
QUERY_IS_TYPE(type, QUERY_TYPE_PREPARE_NAMED_STMT) ||
|
||||
modutil_is_SQL_prepare(queue))
|
||||
command_is_prepare(command))
|
||||
{
|
||||
GWBUF* err = gen_dummy_error(my_session, "This filter does not support "
|
||||
"prepared statements.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user