Обсуждение: how to emit line number in a function?
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? Cheers, Bricklen -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________
Bricklen Anderson wrote: > 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? I don't think you can do so yourself. However, recent versions of PG should display the line number of a RAISE NOTICE or similar if you have the error verbosity high enough. -- Richard Huxton Archonet Ltd
Richard Huxton wrote: > Bricklen Anderson wrote: > >>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? > > > I don't think you can do so yourself. However, recent versions of PG > should display the line number of a RAISE NOTICE or similar if you have > the error verbosity high enough. > Okay, thanks for the head's up. Is there any other way to get the current line number, for example, an inline function call to elog(?) or something? It's not a huge deal, but it would be useful for debugging and timings. -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________
On Thu, Nov 03, 2005 at 09:25:27AM -0800, Bricklen Anderson wrote: > Richard Huxton wrote: > > Bricklen Anderson wrote: > > > >>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? > > > > > > I don't think you can do so yourself. However, recent versions of PG > > should display the line number of a RAISE NOTICE or similar if you have > > the error verbosity high enough. > > > Okay, thanks for the head's up. > Is there any other way to get the current line number, for example, an inline > function call to elog(?) or something? It's not a huge deal, but it would be > useful for debugging and timings. This seems to be something useful to have... can we get a TODO? Unless maybe Bricklen wants to submit a patch... :) -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
Jim C. Nasby wrote: > This seems to be something useful to have... can we get a TODO? Unless > maybe Bricklen wants to submit a patch... :) I can barely even spell C ... -- _______________________________ This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. _______________________________
Bricklen Anderson <BAnderson@presinet.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/
Jerry Sievers wrote:
> Bricklen Anderson <BAnderson@presinet.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
>
I'll look into that, thanks for the suggestion.
Cheers,
Bricklen
--
_______________________________
This e-mail may be privileged and/or confidential, and the sender does
not waive any related rights and obligations. Any distribution, use or
copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in
error, please advise me (by return e-mail or otherwise) immediately.
_______________________________