Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: reset connect在哪个版本开始支持?
[Test Environment for TiDB] Testing
[TiDB Version] v4.0.16
[Reproduction Path] None
[Encountered Issue: Phenomenon and Impact]
I would like to ask which version started supporting this issue?
The test environment is v4.0.16, and it reports an error:
[command=“Reset connect”] [status=“inTxn:0, autocommit:1”] [sql=“Reset connect”] [txn_mode=PESSIMISTIC] [err=“ERROR 1105 (HY000): command 31 not supported now”]
The production environment is v6.5.3, and it does not report an error.
I found something similar on GitHub, but I didn’t see which version it was fixed in.
pingcap:master
←
opened 06:09PM - 30 Jul 20 UTC
### What problem does this PR solve?
Issue Number: Fixes https://github.com/p… ingcap/tidb/issues/3665 Fixes https://github.com/pingcap/tidb/issues/4640
Problem Summary:
### What is changed and how it works?
What's Changed:
There are several legacy RPC commands which TiDB does not support. This reorganizes the main dispatcher to follow the same order as the protocol to make it clearer which ones are missing.
Support for ComRefresh (often used with mysqldump -F to rotate binary logs), ComShutdown (legacy, but may still be used by an old client) and ComResetConnection (a 5.7+ faster way for connection pools to reset. Currently the go mysql driver does not use it. I wrote a sample program in C.)
I attempted to add ComStatistics, but the RPC is requires a different response packet. So I am going to skip for now.
How it Works:
Shutdown and Refresh (Flush Privileges) are redirected to SQL commands.
Remaining refresh commands are noops.
### Related changes
None
### Check List
Tests
- Unit test
- Manual test
I manually verified that shutdown from a mysql 5.6 client (mysqladmin shutdown) works.
The following C program verifies that reset connection is correct:
```
/*
* gcc example.c -o example `mysql_config --cflags --libs`
*/
#include <mysql.h>
#include <stdio.h>
void check_user_var(MYSQL *conn) {
if (mysql_query(conn, "SELECT @acdc;")) {
fprintf(stderr, "%s\n", mysql_error(conn));
}
MYSQL_RES *result = mysql_store_result(conn);
if (result == NULL) {
fprintf(stderr, "%s\n", mysql_error(conn));
}
MYSQL_ROW row;
while ((row = mysql_fetch_row(result))) {
fprintf(stderr, "acdc=%s\n", row[0]);
}
mysql_free_result(result);
}
void set_user_var(MYSQL *conn) {
fprintf(stderr, "SET @acdc = '32';\n");
mysql_query(conn, "SET @acdc = '32'");
}
void select_database(MYSQL *conn) {
if (mysql_query(conn, "SELECT DATABASE()")) {
fprintf(stderr, "%s\n", mysql_error(conn));
}
MYSQL_RES *result = mysql_store_result(conn);
if (result == NULL) {
fprintf(stderr, "DB: %s\n", mysql_error(conn));
}
MYSQL_ROW row;
while ((row = mysql_fetch_row(result))) {
fprintf(stderr, "DB: %s\n", row[0]);
}
mysql_free_result(result);
}
void check_databases(MYSQL *conn) {
if (mysql_query(conn, "SHOW DATABASES")) {
fprintf(stderr, "%s\n", mysql_error(conn));
}
MYSQL_RES *result = mysql_store_result(conn);
if (result == NULL) {
fprintf(stderr, "%s\n", mysql_error(conn));
}
MYSQL_ROW row;
while ((row = mysql_fetch_row(result))) {
fprintf(stderr, "%s\n", row[0]);
}
mysql_free_result(result);
}
int main(int argc, char **argv) {
MYSQL *conn = mysql_init(NULL);
if (conn == NULL) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
if (mysql_real_connect(conn, "127.0.0.1", "special", "", "special", 4000, NULL, 0) == NULL) {
fprintf(stderr, "%s\n", mysql_error(conn));
mysql_close(conn);
exit(1);
}
check_user_var(conn);
set_user_var(conn);
check_user_var(conn);
check_databases(conn);
select_database(conn);
fprintf(stderr, "-- reset-connection- \n");
mysql_reset_connection(conn);
check_user_var(conn);
check_databases(conn);
select_database(conn);
mysql_close(conn);
exit(0);
}
```
Output:
```
nullnotnil@ubuntu:~$ gcc example.c -o example `mysql_config --cflags --libs` && ./example
acdc=(null)
SET @acdc = '32';
acdc=32
INFORMATION_SCHEMA
special
DB: special
-- reset-connection-
acdc=(null)
INFORMATION_SCHEMA
special
DB: special
```
Side effects
- More code complexity for not very common use cases (legacy protocol features)
### Release note
- Support for legacy SHUTDOWN, FLUSH and RESET CONNECTION binary protocol commands added
I just checked, and I couldn’t find it either~
Only merged into master. So it will follow the major version.
The next major version after 4.0 is 5.0.
The release date for 5.0 is:
Release Date: April 7, 2021
Later than the submission time of the above PR:
Aug 11, 2020
So it should be fixed starting from version 5.0.
Indeed, I upgraded version by version yesterday, and it worked fine after upgrading to v5.0.0.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.