Re: [RFC] obtaining the function call stack - Mailing list pgsql-hackers

From decibel
Subject Re: [RFC] obtaining the function call stack
Date
Msg-id 2174D75E-684C-4927-A1FA-8E80E43C3FAB@decibel.org
Whole thread Raw
In response to Re: [RFC] obtaining the function call stack  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Jul 13, 2009, at 2:02 PM, Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
>> So, the idea is to have a stack maintained by the function  
>> manager; each
>> called function enters an element in it containing the interesting
>> information about the function.  We'd have another function that  
>> would
>> return this stack as a result set.  (With this arrangement, the  
>> topmost
>> element would always appear to be this "peek" function.)
>
>> I haven't looked at the code to see how this would actually be
>> implemented, so I don't have more details to offer.  Does anybody  
>> have
>> opinions on the matter?
>
> The performance and error recovery implications are unfavorable.
> Just how badly do you need this, and for what?


The immediate goal is to be able to control debug output based on  
what function you're in, so that you don't get swampped by tons of  
debug output if you do SET client_min_messages = debug. (This is  
assuming you tend to write functions that have a bunch of RAISE DEBUG  
in them).

In this case, all we'd care about is the function that called us.  
There are other times when I've wanted to know what function I'm  
actually in, though I think that's almost always been because RAISE  
DEBUG doesn't provide that context.

So, if it makes it easier, we could probably get by with just the  
function that called us. Another possible option would be if there  
was a way to get our function name (which we could then pass on to  
the debug output function).
-- 
Decibel!, aka Jim C. Nasby, Database Architect  decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828




pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [RFC] obtaining the function call stack
Next
From: Peter Eisentraut
Date:
Subject: Alpha release process