Re: [PATCHES] Warning for missing createlang

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(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 16:23:31
Message-ID: 25137.1062779011@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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?

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message luke 2003-09-05 16:27:29 win32
Previous Message Mendola Gaetano 2003-09-05 16:15:03 Re: C++ and using C functions

Browse pgsql-patches by date

  From Date Subject
Next Message Robert Treat 2003-09-05 17:01:12 Re: psql \h alter scrolls of screen
Previous Message Tom Lane 2003-09-05 16:13:56 Re: doc patch - linux memory handling