From 86c97a210936a95612ae714f76afe9475c3a8029 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 17 Jan 2017 16:13:56 +0200 Subject: [PATCH] Analyze binary prepared statements as well Now that the query classifier can be given COM_STMT_PREPARE packets in addition to COM_QUERY packets, binary prepared statements will be subject to the same analyses as any other statement. --- server/modules/filter/dbfwfilter/dbfwfilter.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/server/modules/filter/dbfwfilter/dbfwfilter.c b/server/modules/filter/dbfwfilter/dbfwfilter.c index 49731cab3..3e983268e 100644 --- a/server/modules/filter/dbfwfilter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter/dbfwfilter.c @@ -2349,20 +2349,16 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue) my_session->errmsg = NULL; rval = dcb->func.write(dcb, err); } - else if (qc_query_is_type(type, QUERY_TYPE_PREPARE_STMT) || - modutil_is_SQL_prepare(queue)) - { - GWBUF* err = gen_dummy_error(my_session, "This filter does not support " - "binary prepared statements."); - gwbuf_free(queue); - MXS_FREE(my_session->errmsg); - my_session->errmsg = NULL; - rval = dcb->func.write(dcb, err); - } else { GWBUF* analyzed_queue = queue; + // QUERY_TYPE_PREPARE_STMT need not be handled separately as the + // information about statements in COM_STMT_PREPARE packets is + // accessed exactly like the information of COM_QUERY packets. However, + // with named prepared statements in COM_QUERY packets, we need to take + // out the preparable statement and base our decisions on that. + if (qc_query_is_type(type, QUERY_TYPE_PREPARE_NAMED_STMT)) { analyzed_queue = qc_get_preparable_stmt(queue);