vapor / mysql-kit

🐬 Pure Swift MySQL client built on non-blocking, event-driven sockets.
MIT License
222 stars 74 forks source link

SimpleQuery fails decoding data version : +3.0.0 #279

Closed pankajsoni19 closed 4 years ago

pankajsoni19 commented 4 years ago

I am connecting to MySql server running on top of ClickHouse DB.

var connection: MySQLConnection
let query = "SELECT count(*) AS count FROM ch_recognitions;"
connection.simpleQuery(query).

there are packets being received in `decodeTextProtocol` >
case .rows(let columnCount, var remaining):

however it the code just loops on needMoreData

pankajsoni19 commented 4 years ago

There are trailing 0's remaining in buffer after decoding MySQLColumnDefinition41

pankajsoni19 commented 4 years ago

wireshark

char peer1_2[] = { /* Packet 295 */
0x01, 0x00, 0x00, 0x01, 0x01, 0x1c, 0x00, 0x00, 
0x02, 0x03, 0x64, 0x65, 0x66, 0x00, 0x00, 0x00, 
0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x00, 0x0c, 
0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xa0, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 
0x03, 0x07, 0x36, 0x34, 0x30, 0x38, 0x33, 0x35, 
0x31 };
tanner0101 commented 4 years ago

Could you try using query instead of simpleQuery and see if the issue persists?

I'm unfortunately not able to repro this with the info here. More information would help. A .pcap file for replaying the session would probably do it if you already have wireshark setup.

The best way to repro would be a small project that exhibits the bug that I can dig into.

pankajsoni19 commented 4 years ago

This was for connecting with Clickhouse Server. It doesn't support parameterised queries. Thus the reason to use simpleQuery. I have since switched to using Rest protocol since I couldn't fix the sql driver easily.