From 454f195cb03d05e5692f18170fc26db0ed36b27d Mon Sep 17 00:00:00 2001 From: Dapeng Huang <7xerocha@gmail.com> Date: Sat, 13 Jan 2018 12:54:12 +0800 Subject: [PATCH] fix:cannot connect to maxinfo with python client --- .gitignore | 9 +++++++++ server/modules/routing/maxinfo/maxinfo.c | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 70154a506..f47acb69a 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,12 @@ CMakeFiles/* */*/*/*/CMakeFiles/* Makefile /.DS_Store + +# Netbeans Project files +nbproject/ +/build/ + +# RBCommons +.reviewboardrc +# vscode +.vscode diff --git a/server/modules/routing/maxinfo/maxinfo.c b/server/modules/routing/maxinfo/maxinfo.c index 63c84e3bf..81646620a 100644 --- a/server/modules/routing/maxinfo/maxinfo.c +++ b/server/modules/routing/maxinfo/maxinfo.c @@ -61,7 +61,7 @@ static int maxinfo_statistics(INFO_INSTANCE *, INFO_SESSION *, GWBUF *); static int maxinfo_ping(INFO_INSTANCE *, INFO_SESSION *, GWBUF *); static int maxinfo_execute_query(INFO_INSTANCE *, INFO_SESSION *, char *); static int handle_url(INFO_INSTANCE *instance, INFO_SESSION *router_session, GWBUF *queue); - +static int maxinfo_send_ok(DCB *dcb); /* The router entry points */ static MXS_ROUTER *createInstance(SERVICE *service, char **options); @@ -356,7 +356,7 @@ execute(MXS_ROUTER *rinstance, MXS_ROUTER_SESSION *router_session, GWBUF *queue) switch (MYSQL_COMMAND(queue)) { case COM_PING: - rc = maxinfo_ping(instance, session, queue); + rc = maxinfo_send_ok(session->dcb); break; case COM_STATISTICS: rc = maxinfo_statistics(instance, session, queue); @@ -618,7 +618,7 @@ maxinfo_execute_query(INFO_INSTANCE *instance, INFO_SESSION *session, char *sql) respond_starttime(session->dcb); return 1; } - if (strcasecmp(sql, "set names 'utf8'") == 0) + if (strncasecmp(sql, "set names", 9) == 0) { return maxinfo_send_ok(session->dcb); } @@ -626,6 +626,10 @@ maxinfo_execute_query(INFO_INSTANCE *instance, INFO_SESSION *session, char *sql) { return maxinfo_send_ok(session->dcb); } + if (strncasecmp(sql, "set @@session", 13) == 0) + { + return maxinfo_send_ok(session->dcb); + } if (strncasecmp(sql, "set autocommit", 14) == 0) { return maxinfo_send_ok(session->dcb);