Re: newbie debugging pl/pgsql : better way? - Mailing list pgsql-general

From Tom Lane
Subject Re: newbie debugging pl/pgsql : better way?
Date
Msg-id 27508.972456512@sss.pgh.pa.us
Whole thread Raw
In response to Re: newbie debugging pl/pgsql : better way?  (Ashley Clark <aclark@ghoti.org>)
List pgsql-general
Ashley Clark <aclark@ghoti.org> writes:
>> Is there a better way to debug pl/pgsql functions?

> If you find it let me know.

The postmaster log should have useful tidbits.  Make sure there *is*
a postmaster log --- start the postmaster without -S, and with its
stdout and stderr directed into a logfile in some handy place.

Then run the misbehaving application with debug options set to -d2
or higher, eg
    export PGOPTIONS="-d2"
    psql mydb
    mydb> -- do your worst here

The log will show the primitive SQL queries generated by plpgsql
functions, as well as the error messages from them.  This is usually
a large leg up on figuring out the problem.  If you're still stuck,
post the plpgsql function body and the relevant logfile section on
the pgsql mail lists, and someone will probably be able to help.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problems with genetic optimizer
Next
From: Peter Keller
Date:
Subject: Re: Problems with genetic optimizer