PostgreSQL 过程语言“C"未找到 [英] PostgreSQL procedural language "C" not found
问题描述
我正在尝试在 PostgreSQL 9.2 数据库中使用 PL/R 过程语言.我已经安装了 plr
语言,我正在尝试将它添加到数据库中.当我运行命令 CREATE EXTENSION plr;
时,我收到以下错误:
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
当我使用 select * from pg_language;
列出数据库中的可用语言时,我得到
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)
所以有一种语言 c
但它不是大写字母(不确定这是否有区别).
So there is a language c
but it is not in capital letters (not sure if that makes a difference).
我想知道为什么 plr
扩展找不到 C
过程语言?
I am wondering why the plr
extension does not find the C
procedural language?
推荐答案
您可能正在 PostgreSQL 9.2 中遇到此更改(引用 此处为发行说明):
You are probably running into this change in PostgreSQL 9.2 (quoting the release notes here):
不再在 CREATE 中强制小写程序语言名称功能(罗伯特·哈斯)
No longer forcibly lowercase procedural language names in CREATE FUNCTION (Robert Haas)
虽然未加引号的语言标识符仍然是小写的,但字符串和带引号的标识符不再被强制小写.因此例如CREATE FUNCTION ... LANGUAGE 'C' 将不再有效;一定是拼写为c",或者最好省略引号.
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.
这也反映在 CREATE FUNCTION<的手册中/code>
lang_name
实现函数的语言名称.可以是SQL
、C
、internal
或用户名- 定义的程序语.为了向后兼容,名称可以用单引号.
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.
至少从 7.3 版(可能更长)开始,不鼓励引用语言名称,但显然旧习惯很难改掉.删除围绕 'C'
的引号可以解决问题,得到:LANGUAGE c
或 LANGUAGE C
.
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
在这方面还没有为 PostgreSQL 9.2 做好准备,从 项目页面.
PL/R
wasn't ready for PostgreSQL 9.2 in that respect, judging from the project page.
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:
我收到消息,只是还没来得及发布新的 PL/R 版本.在 12 月之前寻找它,但同时手动解决方法上面提到的很简单.
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.
这篇关于PostgreSQL 过程语言“C"未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!