Re: [PATCHES] Warning for missing createlang

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Warning for missing createlang
Date: 2003-09-05 17:18:50
Message-ID: 200309051718.h85HIoi20134@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >> We could answer my objection about the hint popping out on misspelled
> >> language names if the code were to arrange to put out the hint only when
> >> the language name is one of "plpgsql", "pltcl", "pltclu", etc. This
> >> would have to use a hard-coded list of loadable language names, since
> >> by definition looking in pg_language won't help. It would be enough of
> >> a maintenance PITA that I don't especially want to do it ... but it
> >> would ensure that the hint is likely to be relevant.
>
> > OK, new output is:
>
> You forgot pltclu, and I believe plpython is now called plpythonu, and
> I'm not sure whether there's a plperlu, and if you're going to include
> outside-the-distro languages then I am pretty sure there's a plruby.
> See what I mean about the maintenance headache this will cause?

I don't mind the maintenance. I just want people to stop getting stuck
creating plpsql functions. Frankly, I don't care if we only test for
plpgsql (the most common case). It doesn't have to be perfect --- it
only prints a HINT. I willing to put some imperfect code in there to
improve usability.

> BTW, duplicating the ereport is no fun. I'd suggest the coding style
> used in some other places, with errhint called in a conditional
> expression:
>
> ereport(ERROR,
> (errcode(ERRCODE_UNDEFINED_OBJECT),
> errmsg("language \"%s\" does not exist", languageName),
> known_language(languageName) ?
> errhint("You need to use 'createlang' to load the language into the database.") : 0));
>
> where known_language() is a little subroutine that has the strcmp()s.

Here is the new output:

test=> create function xx() returns int as '
test'> select 1'
test-> language 'XXplpgsql';
ERROR: language "xxplpgsql" does not exist
test=> create function xx() returns int as '
test'> select 1'
test-> language 'plpgsql';
ERROR: language "plpgsql" does not exist
HINT: You need to use 'createlang' to load the language into the
database.

Why does the ': 0' work? I didn't figure that would work, but it does.

Patch attached.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2003-09-05 17:24:19 Re: TCP/IP with 7.4 beta2 broken?
Previous Message Bruce Momjian 2003-09-05 17:12:22 Re: Stats Collector Error 7.4beta1 and 7.4beta2

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2003-09-05 17:25:26 Re: [PATCHES] Warning for missing createlang
Previous Message Robert Treat 2003-09-05 17:01:12 Re: psql \h alter scrolls of screen