Re: how to emit line number in a function?

From: Jerry Sievers <jerry(at)jerrysievers(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: how to emit line number in a function?
Date: 2005-11-04 14:22:55
Message-ID: m3ek5w4hmo.fsf@prod01.jerrysievers.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bricklen Anderson <BAnderson(at)presinet(dot)com> writes:

> I couldn't find any useful references in the docs or archives for emitting the
> line number of a plpgsql function (in a RAISE statement). I'd like to use it for
> debugging some complex functions.
> Does anyone have any tips on where to look, or an example of this?

Have a look at the m4 macro processor

changequote({,})dnl
define({func_body},{$$begin
raise exception 'I barfed on line #__line__';
end$$})dnl

create function some_func()
returns whatever
as func_body
language plpgsql;

This can be useful sometimes... but may ADD to your debugging
headaches if not used artfully!

HTH

--
-------------------------------------------------------------------------------
Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
305 321-1144 (mobile http://www.JerrySievers.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message vishal saberwal 2005-11-04 14:24:06 Re: Image File System Question
Previous Message Jerry Sievers 2005-11-04 14:06:58 Re: Changing ids conflicting with serial values?