From a3767fa39ec127234fd0e12fe8bde34519077a4a Mon Sep 17 00:00:00 2001 From: noother Date: Thu, 28 May 2020 16:06:12 +0200 Subject: [PATCH 1/4] fix unquoted table name leading to sql errors --- lib/MySQL_Protocol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index 849d09624..a93df5905 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -2314,7 +2314,7 @@ bool MySQL_Protocol::generate_COM_QUERY_from_COM_FIELD_LIST(PtrSize_t *pkt) { (*myds)->com_field_wild=strdup(wild); } - char *qt = (char *)"SELECT * FROM %s WHERE 1=0"; + char *qt = (char *)"SELECT * FROM `%s` WHERE 1=0"; q = (char *)malloc(strlen(qt)+strlen(tablename)); sprintf(q,qt,tablename); l_free(pkt->size, pkt->ptr); From 416260ab53414d53d4e697916fb196e8c8aa909e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 29 May 2020 13:14:28 +0200 Subject: [PATCH 2/4] Ignore last semicolon from SET statements #2838 --- lib/MySQL_Session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 9dd4a0c00..ef97b4555 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -4898,7 +4898,7 @@ bool MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C proxy_debug(PROXY_DEBUG_MYSQL_QUERY_PROCESSOR, 5, "Parsing SET command = %s\n", nqn.c_str()); } #endif - if (index(dig,';')) { + if (index(dig,';') && (index(dig,';') != dig + strlen(dig)-1)) { string nqn = string((char *)CurrentQuery.QueryPointer,CurrentQuery.QueryLength); proxy_warning("Unable to parse multi-statements command with SET statement: setting lock hostgroup . Command: %s\n", nqn.c_str()); *lock_hostgroup = true; From f384a9225efdcf4530816138dd9691e69cf8688d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 7 Jun 2020 22:35:47 +0200 Subject: [PATCH 3/4] Prevent crash if CHARACTER_SET_CONNECTION is not initialized yet #2863 --- lib/mysql_connection.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 5619a7b59..5669dfd20 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -78,7 +78,10 @@ void Variable::fill_client_internal_session(json &j, int idx) { } else if (idx == SQL_CHARACTER_SET_CONNECTION) { const MARIADB_CHARSET_INFO *ci = NULL; - ci = proxysql_find_charset_nr(atoi(value)); + if (!value) + ci = proxysql_find_charset_collate(mysql_tracked_variables[idx].default_value); + else + ci = proxysql_find_charset_nr(atoi(value)); j["conn"][mysql_tracked_variables[idx].internal_variable_name] = (ci && ci->csname)?ci->csname:""; } else if (idx == SQL_COLLATION_CONNECTION) { const MARIADB_CHARSET_INFO *ci = NULL; From 7b82a3774a89cf4992818c10425b22b89c7a16ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Mon, 8 Jun 2020 18:17:19 +0200 Subject: [PATCH 4/4] Set 'with_gtid' flag each time a GITD is going to be used --- lib/MySQL_Session.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index ef97b4555..9f0a94d0b 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -5770,11 +5770,13 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED if (session_fast_forward == false) { if (qpo->min_gtid) { gtid_uuid = qpo->min_gtid; + with_gtid = true; } else if (qpo->gtid_from_hostgroup >= 0) { _gtid_from_backend = find_backend(qpo->gtid_from_hostgroup); if (_gtid_from_backend) { if (_gtid_from_backend->gtid_uuid[0]) { gtid_uuid = _gtid_from_backend->gtid_uuid; + with_gtid = true; } } }