Bug #16982 | Stored procedure OUT parameters can't be used until after other results fetched | ||
---|---|---|---|
Submitted: | 31 Jan 2006 16:24 | Modified: | 10 Feb 2006 8:36 |
Reporter: | Andy Dustman | Email Updates: | |
Status: | Won't fix | Impact on me: | |
Category: | MySQL Server | Severity: | S4 (Feature request) |
Version: | 5.0.18 | OS: | independent |
Assigned to: | CPU Architecture: | Any |
[31 Jan 2006 16:24]
Andy Dustman
[9 Feb 2006 13:32]
Valeriy Kravchuk
Thank you for a problem report. I think, it is a reasonable C API/protocol feature request. So, I mark it as verified.
[9 Feb 2006 15:05]
Per-Erik Martin
This is, to put it bluntly, impossible. This is how it works: 1) The client sends CALL simpleproc(@foo) to the server, and waits for a response. 2) The server executes simpleproc: 2.1) SELECT INTO param1 is executed, only the local parameter is yet set, not @foo 2.2) SELECT * FROM t is executed. The result set is now being sent back to the client. 2.3) Since execution was successful, OUT parameters are set in the caller's context - in this case the user variable @foo. 2.4) The response is finalized (send_ok). 3) The client processes the result set. It's after 3 it's possible to send new queries to the server. It's not possible to make the output value available until the entire procedure has finished successfully; the parameter might be set several times during execution, and if an error aborts execution it should not be set at all. Even if it was possible to send a request to get @foo before processing the result set (which would require a redesign of the client protocol), it wouldn't help, since @foo has has not yet been set; it can't be set until the procedure returns. Even if the server were to send out parameters as a result set, it can only be done when the procedure execution has succeeded, i.e. after any other result sets have been sent, so it doesn't help to add any special C API function at the client end for this. It's actually not possible for another procedure, calling simpleproc, to make use of out parameters before the result set is "processed" (in the server it's "sent"), the calling procedure wont "see" the value until it's resuming execution after the CALL.
[10 Feb 2006 8:36]
Valeriy Kravchuk
So, looks like this will not be implemented.