tags:

views:

160

answers:

2

I would like to have access to Seconds_Behind_Master (as returned by SHOW SLAVE STATUS) from inside a stored procedure, but can't figure out how to get its value inside a variable. None of the usual SET/SELECT syntax seems to work. Is there a way to do that?

+1  A: 

From what I see in the recent docs and MySQL Bug#37187 there does not seem to be any way but SHOW SLAVE STATUS to get to this information.

Daniel Schneller
The problem is that SHOW SLAVE STATUS can be used from the outside (e.g. from a perl script), but how can I parse it from a stored procedure?
azerole
+1  A: 

Just for the record: it has turned out to be possible to open a cursor for SHOW statements. This allows to parse the output and work with it inside a stored procedure.

azerole
Azerole, do you have sample code by any chance? I can't seem to get it to work.
Artem
Yes, but it's 5.0 only. In 5.1 there is an unfixed bug in mysql that prevents opening cursors on SHOW.
azerole