Re: [RFC] obtaining the function call stack

From: decibel <decibel(at)decibel(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [RFC] obtaining the function call stack
Date: 2009-07-13 19:30:30
Message-ID: 2174D75E-684C-4927-A1FA-8E80E43C3FAB@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jul 13, 2009, at 2:02 PM, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)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(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2009-07-13 19:32:55 Alpha release process
Previous Message Alvaro Herrera 2009-07-13 19:26:53 Re: [RFC] obtaining the function call stack