Bug #19794 Stored Procedures: No way to "print" log messages to clients
Submitted: 13 May 2006 12:48 Modified: 3 Oct 2008 9:09
Reporter: Paul Medynski Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S4 (Feature request)
Version:5.1.7-beta-log OS:Linux (Linux 2.4.27-2-386)
Assigned to: CPU Architecture:Any

[13 May 2006 12:48] Paul Medynski
Description:
Debugging stored procedures is very difficult without a way to send diagnostic log messages to the client for logging.  Sybase has "print" and "raiserror" functions that accomplish this very well.  From the client, you can easily see what the stored procedure is doing, which is essential for both developers debugging their work, and for operations to diagnose problems.  The printed text would have to flow back from the MySQL server as it occurs, intermixed with any result sets.  However, it cannot be a result set because the client only expects the exact number of result sets advertised by the scored procedure.  Adding result sets for each print statement would break the interface.  This is probably not easily supported by the current MySQL client/server protocol :(

Suggested syntax:

# sends "Hello" to the client
print "Hello.";

# sends "Hello Chet, you have 38 emails." to the client
print concat("Hello", vUserName, ", you have ", vEmailCount, " emails.");

How to repeat:
No repeatable, because the feature doesn't exist.

Suggested fix:
Add some kind of "print" function to send text back to the client.
[15 May 2006 20:30] Valeriy Kravchuk
Thank you for a feature request. For logging, why not just to INSERT you messages into (temporary, HEAP, MyISAM) a table, with timestamp and (for non-temporary table) session ID? Then your client application (or you, from another session) can just SELECT any part of that messages log (and delete messages, if not needed any more). Oracle's DBMS_OUTPUT package (used for SPs debugging) is working in that way.

Yopu can create a nice SP called "print" for that, if you want.
[15 Jun 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[3 Oct 2008 9:10] Valeriy Kravchuk
Bug #32747 was marked as a duplicate of this one.