Skip to content

Commit

Permalink
fix mysql protocol (#436)
Browse files Browse the repository at this point in the history
### What problem were solved in this pull request?
in mysql protocol, if client doesn't support CLIENT_SESSION_TRACK,
server shouldn't send any status info.

ref:
https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html

Issue Number: close #xxx

Problem:

### What is changed and how it works?

### Other information
  • Loading branch information
nautaa authored Aug 8, 2024
1 parent 77ed3c3 commit cd8adf0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/design/miniob-mysql-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ packet header包含payload的长度和当前消息包的sequence。sequence是

这里有两次hash加密,基于随机挑战码和密码加密后返回给server端。

MyqlCommunicator::init是在刚接收到新的客户端连接时的接口,它会构造一个握手包发给客户端。在第一次接收客户端数据时,即在MysqlCommunicator::read_event中,如果判断还没有做过鉴权,就会做一个特殊处理,判断是否可以认证通过。不过当前MiniOB不会真的做密码验证。如果已经做过鉴权,就会认为接收的数据包是一个普通的命令消息。在接收到客户端的认证报文后,需要返回OK包给客户端。
MysqlCommunicator::init是在刚接收到新的客户端连接时的接口,它会构造一个握手包发给客户端。在第一次接收客户端数据时,即在MysqlCommunicator::read_event中,如果判断还没有做过鉴权,就会做一个特殊处理,判断是否可以认证通过。不过当前MiniOB不会真的做密码验证。如果已经做过鉴权,就会认为接收的数据包是一个普通的命令消息。在接收到客户端的认证报文后,需要返回OK包给客户端。

**OK包报文**

Expand Down
2 changes: 0 additions & 2 deletions src/observer/net/mysql_communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ struct OkPacket : public BasePacket

if (capabilities & CLIENT_SESSION_TRACK) {
pos += store_lenenc_string(buf + pos, info.c_str());
} else {
pos += store_fix_length_string(buf + pos, info.c_str(), info.length());
}

int32_t payload_length = pos - 4;
Expand Down

0 comments on commit cd8adf0

Please sign in to comment.