Philio / GoMySQL

The most complete and stable MySQL client library written completely in Go. For discussion, ideas, suggestions, feature requests etc, please visit the GoMySQL Google Group (link below). For any issues/bugs or need some help, please post an issue on Github.
https://groups.google.com/group/gomysql
Other
189 stars 42 forks source link

Read reset response #25

Closed thomaslee closed 13 years ago

thomaslee commented 13 years ago

Hi Phil,

This fixes the bug I alluded to in #7, where Reset() sends a COM_RESET_STMT but doesn't read the response. Suspect SendLongData suffers the same problem, but have not verified this.

The code's beginning to feel like it could use a bit of refactoring love in the response processing side of things :)

Cheers, Tom

Philio commented 13 years ago

Hi Tom,

I'm pretty sure both reset and long data commands do not receive a response from the server.

Check the docs for more info: http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol

I did skim the docs, but didn't see it, but I'm sure it says something somewhere. I'm travelling at the moment so not the most convenient time to check!

thomaslee commented 13 years ago

Ah, SendLongData sends no response:

http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#Long_Data_Packet_.28Tentative_Description.29

"The server will not send an ok or error packet in response to this. If there is an error (for example the string is too big), one will see the error when calling "execute"."

No such exception for reset though as near as I can see. Based on the behaviour I'm seeing from a simple test program (BindParams(), Execute(), Reset(), Execute()), the server does indeed respond to a COM_RESET_STMT.

Maybe try it yourself & see if you can reproduce it -- entirely possible I'm just drunk. :)

Philio commented 13 years ago

Possibly this is an oversight on my part then.

Prepared statements were also somewhat of a hack add on to the original code, it was the trickiest part to implement too and clearly I've made a few mistakes with it.

I think the whole packet / response processing could probably do with a complete overhaul tbh. I think it would be nicer to have a work flow something like...

Read packet header Read entire packet data Pass entire packet to processing script Parse response and pass back to calling function