Re: error messages VERY misleading...!

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: will trillich <will(at)serensoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: error messages VERY misleading...!
Date: 2001-03-21 14:46:44
Message-ID: Pine.BSF.4.21.0103210645040.34533-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Wed, 21 Mar 2001, will trillich wrote:

> DECLARE
> val int4;
> BEGIN
> -- minutes
> val := int( date_part(''epoch'',current_timestamp - $1) / 60 ) ;
> IF val < 60 THEN
> val := val / 5; -- round down to 5-minute chunks
> IF val < 1
> val := 1;
> END IF;
> return (val * 5) || '' min'';
> END IF;
> -- other time chunks follow
> END;
> ' LANGUAGE 'plpgsql';
>
>
> do you see the problem? i sure didn't, not for SEVEN HOURS
> (thankyouverymuch). here's why:
>
>
> psql=> SELECT showage( CURRENT_TIMESTAMP );
> ERROR: parser: parse error at or near "$2"
>
>
> now WHO in their right mind would expect anyone to interpret
> 'parse error at $2' as '"IF" needs a "THEN", bubba; where's the
> "THEN", hmm?'?
>
> what $2? there's barely a $1! $2? WTF?
>
> AAUGH!
>
> </bitchmode>
>
> now, i know parsing for compilers/interpreters is a daunting
> task, and meaningful error messages aren't easy to generate...
> in postgresql plpgperl, you're lucky to get a relative line
> number. but i gotta admit, 'near $2' takes the cake! WOW.

My guess is that the variables are treated as $ things
($1 in this case is your argument, $2 == val)

So it's complaining at the val:=1 line.

Yeah, those messages could use help.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mayers, Philip J 2001-03-21 14:48:09 MACADDR types NULL value (undocumented?)
Previous Message Culley Harrelson 2001-03-21 14:42:17 Implementing cascading deletes on an existing table