waiting for 8.4 - current_query()
unfrotunatelly i can’t point you to message in archives, as there is some problem with them, and i dont see posts newer than “Fri Apr 04 12:00:08 2008″.
this patch was written by tomas doran, and commited by bruce momjian: