You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since issue #656 was closed without progress, I was trying to get OUT parameters for stored procedure calls working. This is what I did:
Add clientPSMultiResults to writeHandshakeResponsePacket in packets.go:
func (mc*mysqlConn) writeHandshakeResponsePacket(authResp []byte, pluginstring) error {
// Adjust client flags based on server supportclientFlags:=clientProtocol41|clientSecureConn|clientLongPassword|clientTransactions|clientLocalFiles|clientPluginAuth|clientMultiResults|clientPSMultiResults|// Tell MySQL that we want OUT Parameters as a separate result setclientConnectAttrs|mc.flags&clientLongFlag
What happens then is that MySQL sends a separate result set with one row and each OUT parameter as a column in order as they are defined in the Procedure signature. Since support for multiple result sets is already implemented, I could do an example implementation of how to call a stored procedure with in and out parameters:
varmyOutValueintresult, err:=CallGet("add_one", 1, sql.Out{ Dest: &myOutValue, In: false })
// myOutValue will now be 2
given the following stored procedure:
CREATE PROCEDURE add_one (
IN v_val INT,
OUT v_result INT)
DETERMINISTIC
BEGIN# set out paramSELECT v_val +1 INTO v_result;
# plain old resultSELECT'hello world';
END
The upside is, that with a single line of code change it will be possible to support Out params, but it still has to be parsed on the side of the using application. I'm sure with a little more research it could be implemented as part of the driver package to do the work of my example CallGet, since MySQL is flagging the result set with SERVER_PS_OUT_PARAMS:
Since issue #656 was closed without progress, I was trying to get OUT parameters for stored procedure calls working. This is what I did:
clientPSMultiResults
towriteHandshakeResponsePacket
inpackets.go
:What happens then is that MySQL sends a separate result set with one row and each OUT parameter as a column in order as they are defined in the Procedure signature. Since support for multiple result sets is already implemented, I could do an example implementation of how to call a stored procedure with in and out parameters:
And I can simply do:
given the following stored procedure:
The upside is, that with a single line of code change it will be possible to support Out params, but it still has to be parsed on the side of the using application. I'm sure with a little more research it could be implemented as part of the driver package to do the work of my example
CallGet
, since MySQL is flagging the result set withSERVER_PS_OUT_PARAMS
:https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_command_phase_sp.html#sect_protocol_command_phase_sp_multi_resultset_out_params
I'm sure it can be done if there is interest in this from anyone?
The text was updated successfully, but these errors were encountered: