error messages VERY misleading...!

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: error messages VERY misleading...!
Date: 2001-03-21 10:48:58
Message-ID: 20010321044858.A28329@mail.serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

with postgresql 7.0.3 (debian/potato)--

<bitchmode attitude=on volume=really-loud>

CREATE DATABASE testorama;

\c testorama

CREATE FUNCTION int(float8) RETURNS int4 AS '
SELECT to_number(to_char( $1 , ''9999999999'') , ''9999999999'')::int4;
' LANGUAGE 'sql';

CREATE FUNCTION showage(datetime) RETURNS varchar AS '
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.

--
will(at)serensoft(dot)com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-03-21 11:13:46 Re: Call for platforms
Previous Message will trillich 2001-03-21 10:21:41 Re: stored procedures on PERL