postgresql 无法访问文件“$libdir/plpgsql”:没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20827761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not access file "$libdir/plpgsql": No such file or directory
提问by CaffeinatedDave
I'm at a loss, I'm having issues creating a stored proc in my local Postgres server (postgres.app, Mac OS X 10.7), as so
我不知所措,我在本地 Postgres 服务器(postgres.app,Mac OS X 10.7)中创建存储过程时遇到问题,因此
$ psql
psql (9.3.0)
Type "help" for help.
dchaston=# CREATE OR REPLACE FUNCTION table_update()
dchaston-# RETURNS TRIGGER AS $$
dchaston$# BEGIN
dchaston$# NEW.last_edit = now();
dchaston$# RETURN NEW;
dchaston$# END;
dchaston$# $$ language 'plpgsql';
ERROR: could not access file "$libdir/plpgsql": No such file or directory
I've checked the following:
我检查了以下内容:
Languages installed:
安装的语言:
dchaston=# select * from pg_language;
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 | 12019 | 12020 | 12021 |
(4 rows)
lib directory (and pkglibdir just in case):
lib 目录(和 pkglibdir 以防万一):
$ pg_config --libdir
/Applications/Postgres.app/Contents/MacOS/lib
$ pg_config --pkglibdir
/Applications/Postgres.app/Contents/MacOS/lib
File present:
文件存在:
$ cd /Applications/Postgres.app/Contents/MacOS/lib; ls plpg*
plpgsql.so
DLSUFFIX set correctly:
DLSUFFIX 设置正确:
lib/pgxs/src/Makefile.shlib:135: DLSUFFIX = .so
Have tried uninstalling and reinstalling, but made no difference. Any ideas?
已尝试卸载并重新安装,但没有任何区别。有任何想法吗?
回答by Erwin Brandstetter
Did you install multiple instances(multiple versions or multiple instances of the same version) of Postgres on the same box? Standard Postgres is not fit for that. Debian or Ubuntu have additional infrastructure to allow multiple versions in parallel. I don't know about OS X, though.
您是否在同一个机器上安装了多个Postgres实例(多个版本或同一版本的多个实例)?标准 Postgres 不适合这种情况。Debian 或 Ubuntu 有额外的基础设施来允许多个版本并行运行。不过,我不知道 OS X。
In standard Postgres the path for $libdir
is compiled into the program. Multiple versions do not get along.
When you execute pg_config --pkglibdir
, make sure it's the one associated with your installation. Run:
在标准 Postgres 中,路径$libdir
被编译到程序中。多个版本不相处。
当您执行 时pg_config --pkglibdir
,请确保它是与您的安装相关联的那个。跑:
which pg_config
Minor notes:
小注:
9.3.0
? It's recommended to always upgrade to the latest point-release, which is 9.3.2 at the moment. Maybe a current source fixes your problem.Also check your settings whether you are using the
$libdir
you think you are using:SELECT * FROM pg_settings WHERE name ~~* '%lib%';
Don't quote the language name
(though it's tolerated). It's an identifier:'plpgsql'
plpgsql
.Use the plpgsql assignment operator:=
.=
is undocumented but tolerated.
Since Postgres 9.4both:=
and=
are documented.
9.3.0
? 建议始终升级到最新的 point-release,目前是 9.3.2。也许当前的来源可以解决您的问题。还要检查您的设置是否正在使用
$libdir
您认为正在使用的:SELECT * FROM pg_settings WHERE name ~~* '%lib%';
不要引用语言名称
(尽管可以容忍)。这是一个标识符:'plpgsql'
plpgsql
。使用 plpgsql赋值运算符:=
。=
没有记录但可以容忍。
从 Postgres 9.4 开始,:=
和=
都有记录。
Otherwise your function definition is fine. That's notthe root of the problem:
否则你的函数定义很好。这不是问题的根源:
CREATE OR REPLACE FUNCTION table_update()
RETURNS trigger AS
$func$
BEGIN
NEW.last_edit := now();
RETURN NEW;
END
$func$ LANGUAGE plpgsql;
回答by Bsantos
I use FreeBSD and found a simple way to solve the problem, just copied the library from another server and pasted it into /usr/local/lib/postgresql/, which is the way $libdir. Although the versions of PostgreSQL are different, everything is working and I had no problems again.
我用的是FreeBSD,找到了一个简单的方法来解决这个问题,直接从另一台服务器复制库,粘贴到/usr/local/lib/postgresql/中,就是$libdir的方式。虽然 PostgreSQL 的版本不同,但一切正常,我再次没有问题。