Re: Result sets from functions

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Liam Caffrey <liam(dot)caffrey(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Result sets from functions
Date: 2012-04-16 15:42:52
Message-ID: CAF-3MvOvqyw-6Laz6fXGd6Bru3+PTdPQVEgx8Ya4ZLadGi81Tg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16 April 2012 09:24, Liam Caffrey <liam(dot)caffrey(at)gmail(dot)com> wrote:
> Hi,
>
> There is a feature that I have used in SQL Server which I find really useful
> for debugging (without using a debugger!!).
> It is this.... I can write multiple "select * from some_table" statements
> throughout my stored procedure (here read "pgsql function") and the
> individual result sets get "returned" to the results pane. This is usually
> to look into the contents of temp tables or intermediate stages. This is
> especially useful when debugging triggers.
>
> I cannot find something similar yet in Postgres. The "return query select *
> from some_table" doesn't do it for me but I have to fiddle with the RETURN
> value of the function definition which I don't want to do.
>
> Does anything like this exist? Could anybody recommend an equally effective
> strategy?

You can use RAISE info and RAISE notice to write session output to a log-file.

I'm fairly confident that if you also set session parameters for
logging, you could capture the messages from just your session in a
separate file or pipe. I'd try this in psql first, but if that works
(I expect it to) any client could do something like that.

Of course, since the logging happens on the server, you'd at least
need the right permissions to write to the file or pipe ;)

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roger Leigh 2012-04-16 15:46:40 Re: The scope of extensions
Previous Message Merlin Moncure 2012-04-16 15:22:19 Re: The scope of extensions