mirror of https://github.com/sysown/proxysql
Merge pull request #3996 from rahim-kanji/v2.x-3992
Fix malformed packet when connected with MariaDB server with fast_forward flag ONv2.x-3698
commit
1c896aea97
@ -0,0 +1,10 @@
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
static inline my_bool ma_has_extended_type_info(const MYSQL *mysql)
|
||||
{
|
||||
- return ((mysql->extension->mariadb_server_capabilities) &
|
||||
- (MARIADB_CLIENT_EXTENDED_METADATA >> 32)) != 0;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static inline uint ma_extended_type_info_rows(const MYSQL *mysql)
|
||||
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file reg_test_3992-fast_forward_malformed_packet-t.cpp
|
||||
* @brief This is a regression test for issue #3992. Test checks if queries are executed successfully with MariaDB
|
||||
* server via mysql client having fast forward flag set to true and false.
|
||||
* @details The test executes basic queries to check execution in MariaDB via mysql client with Fast Forward flags on/off
|
||||
*
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include <mysql.h>
|
||||
|
||||
#include "tap.h"
|
||||
#include "command_line.h"
|
||||
#include "utils.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
CommandLine cl;
|
||||
|
||||
if (cl.getEnv()) {
|
||||
diag("Failed to get the required environmental variables.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> users { {"mariadbuserff", "mariadbuserff"},
|
||||
{"mariadbuser", "mariadbuser"} };
|
||||
|
||||
for (const auto& user : users)
|
||||
{
|
||||
// Test that mysqlsh is able to connect and execute a query
|
||||
const char* mysqlsh_client = "mysqlsh";
|
||||
const std::string mysql_user = std::string("-u") + user.first + " ";
|
||||
const std::string mysql_pass = std::string("-p") + user.second + " ";
|
||||
const std::string mysql_port = std::string("-P") + std::to_string(cl.port) + " ";
|
||||
const std::string host = std::string("-h ") + std::string(cl.host) + " ";
|
||||
|
||||
int mysqlsh_res = system((std::string("mysqlsh ") + std::string("--sql ") + mysql_user + mysql_pass + mysql_port + host + "-e \"SHOW DATABASES\"").c_str());
|
||||
ok(mysqlsh_res == 0, "'mysqlsh' empty select command should be correctly executed. Err code was: %d", mysqlsh_res);
|
||||
|
||||
mysqlsh_res = system((std::string("mysqlsh ") + std::string("--sql ") + mysql_user + mysql_pass + mysql_port + host + "-e \"SELECT 1\"").c_str());
|
||||
ok(mysqlsh_res == 0, "'mysqlsh' empty select command should be correctly executed. Err code was: %d", mysqlsh_res);
|
||||
}
|
||||
|
||||
return exit_status();
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @file reg_test_3992-fast_forward_malformed_packet-t.cpp
|
||||
* @brief This is a regression test for issue #3992. Test checks if queries are executed successfully with MariaDB
|
||||
* server having fast forward flag set to true and false.
|
||||
* @details The test executes basic queries to check execution in MariaDB with Fast Forward flags on/off
|
||||
*
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include <mysql.h>
|
||||
|
||||
#include "tap.h"
|
||||
#include "command_line.h"
|
||||
#include "utils.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
CommandLine cl;
|
||||
|
||||
if (cl.getEnv()) {
|
||||
diag("Failed to get the required environmental variables.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::vector<MYSQL*> conns;
|
||||
|
||||
const std::vector<std::pair<std::string, std::string>> users { {"mariadbuserff", "mariadbuserff"},
|
||||
{"mariadbuser", "mariadbuser"} };
|
||||
|
||||
const std::vector<std::string> queries {"SHOW DATABASES", "SELECT 1"};
|
||||
|
||||
plan(users.size() * queries.size());
|
||||
|
||||
for (const auto& user : users)
|
||||
{
|
||||
MYSQL* mysql = mysql_init(NULL);
|
||||
|
||||
if (!mysql) {
|
||||
fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(mysql));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!mysql_real_connect(mysql, cl.host, user.first.c_str(), user.second.c_str(), NULL, cl.port, NULL, 0)) {
|
||||
fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(mysql));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
conns.push_back(mysql);
|
||||
}
|
||||
|
||||
for (MYSQL* conn : conns)
|
||||
{
|
||||
for (const std::string& query : queries)
|
||||
{
|
||||
const int q_err = mysql_query(conn, query.c_str());
|
||||
|
||||
if (q_err == EXIT_SUCCESS)
|
||||
{
|
||||
MYSQL_RES *result = mysql_store_result(conn);
|
||||
mysql_free_result(result);
|
||||
|
||||
ok(true, "Executing query of size: '%ld', should succeed", query.size());
|
||||
}
|
||||
else
|
||||
ok(false, "Executing query of size: '%ld', should succeed", query.size());
|
||||
}
|
||||
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
return exit_status();
|
||||
}
|
||||
Loading…
Reference in new issue