From 3a8b1bce42b3b120bee21a0d610f0fb9d8f76bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 11 Dec 2020 14:34:34 +0000 Subject: [PATCH] Fixed enforcing 'CLIENT_MULTI_RESULTS' for client connections specifying 'CLIENT_MULTI_STATEMENTS' --- lib/MySQL_Protocol.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index 1c6d42b30..19f1c8ec0 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -1582,6 +1582,14 @@ bool MySQL_Protocol::process_pkt_handshake_response(unsigned char *pkt, unsigned } capabilities = CPY4(pkt); + // see bug #2916. If CLIENT_MULTI_STATEMENTS is set by the client + // we enforce setting CLIENT_MULTI_RESULTS, this is the proper and expected + // behavior (refer to 'https://dev.mysql.com/doc/c-api/8.0/en/c-api-multiple-queries.html'). + // Don't enforcing this would cause a mismatch between client and backend + // connections flags. + if (capabilities & CLIENT_MULTI_STATEMENTS) { + capabilities |= CLIENT_MULTI_RESULTS; + } (*myds)->myconn->options.client_flag = capabilities; pkt += sizeof(uint32_t); max_pkt = CPY4(pkt);