Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL procedural language "C" not found

I am trying to use the PL/R procedural language in a PostgreSQL 9.2 database. I have installed the plr language and I am trying to add it to a database. When I run the command CREATE EXTENSION plr; I get the following error:

ERROR:  language "C" does not exist
STATEMENT:  CREATE EXTENSION plr;
ERROR:  language "C" does not exist

When I list the available languages in the database with select * from pg_language; I get

 lanname  | lanowner | lanispl | lanpltrusted | lanplcallfoid | laninline | lanvalidator | lanacl 
 ----------+----------+---------+--------------+---------------+-----------+--------------+--------
  internal |       10 | f       | f            |             0 |         0 |         2246 | 
  c        |       10 | f       | f            |             0 |         0 |         2247 | 
  sql      |       10 | f       | t            |             0 |         0 |         2248 | 
  plpgsql  |       10 | t       | t            |         12514 |     12515 |        12516 | 
 (4 rows)

So there is a language c but it is not in capital letters (not sure if that makes a difference).

I am wondering why the plr extension does not find the C procedural language?

like image 473
yellowcap Avatar asked Sep 20 '12 14:09

yellowcap


1 Answers

You are probably running into this change in PostgreSQL 9.2 (quoting the release notes here):

No longer forcibly lowercase procedural language names in CREATE FUNCTION (Robert Haas)

While unquoted language identifiers are still lowercased, strings and quoted identifiers are no longer forcibly down-cased. Thus for example CREATE FUNCTION ... LANGUAGE 'C' will no longer work; it must be spelled 'c', or better omit the quotes.

It's also reflected in the manual for CREATE FUNCTION

lang_name

The name of the language that the function is implemented in. Can be SQL, C, internal, or the name of a user-defined procedural language. For backward compatibility, the name can be enclosed by single quotes.

Quoting the language name has been discouraged since at least version 7.3 (maybe longer), but old habits die hard, obviously. Removing the quotes around 'C' fixes the problem, arriving at: LANGUAGE c or LANGUAGE C.

PL/R wasn't ready for PostgreSQL 9.2 in that respect, judging from the project page.

Feedback from Joe Conway

Joe Conway left an answer that got deleted because it should be a comment. I paste it here for the general public who can't see deleted answers:

I got the message, just haven't had the time to do a new PL/R release. Look for it by December, but in the meantime the manual workaround noted above is pretty simple.

like image 168
Erwin Brandstetter Avatar answered Sep 19 '22 23:09

Erwin Brandstetter