Re: Hrm...why is this wrong?

From: Jan Wieck <janwieck(at)Yahoo(dot)com>
To: Ken Corey <ken(at)kencorey(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Hrm...why is this wrong?
Date: 2001-02-08 09:38:44
Message-ID: 200102080938.EAA02707@jupiter.greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ken Corey wrote:
> Wow! Answering emails on a Sunday? Someone should be giving you an award or
> something.
>
> On Sunday 04 February 2001 8:13 pm, you wrote:
> > Ken Corey <ken(at)kencorey(dot)com> writes:
> > > When the select at the bottom of this email is executed, I'm getting the
> > > message:
> > > ERROR: parser: parse error at or near "$1"
> >
> > I don't get that; I get
> > ERROR: Attribute 'username_in' not found
> > which is about what I'd expect for the given function text; maybe you
> > didn't transcribe it accurately?
>
> That's strange...perhaps the difference was a problem with my table
> definition? *shrug* I also had made a few mistakes, so once I got those
> fixed, the code seems to work again.
>
> > Anyway, an invaluable technique for debugging plpgsql functions is to
> > start psql with debug level 2, so that the queries the plpgsql executor
> > feeds to the SQL engine get logged in the postmaster log. (If you don't
> > run the postmaster with a logfile, you should...) For example:
>
> Hey, that's perfect. It's okay just so long as the debugging out goes
> *somewhere*...:^)

Another lesser known trick is to add

#option dump

at the top of the function body (before DECLARE). This
causes the PL/pgSQL compiler to dump out the entire function
after parsing where you can see all the SPI queries that
later will get executed.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2001-02-08 10:59:12 Re: Is this a bug, or is it just me?
Previous Message Michael Miyabara-McCaskey 2001-02-08 06:22:17 RE: FATAL 1: btree: items are out of order (leftmost 0, stack 48, update 2)