PostgreSQL 上 $libdir 的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1349001/
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
Problems with $libdir on PostgreSQL
提问by Joe Germuska
In short, my question is "why doesn't $libdir work on my PSQL installation."
简而言之,我的问题是“为什么 $libdir 在我的 PSQL 安装中不起作用”。
CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d
AS '$libdir/liblwgeom', 'BOX2DFLOAT4_in'
LANGUAGE c IMMUTABLE STRICT;
yields an error
产生错误
could not access file "$libdir/liblwgeom": No such file or directory
while
尽管
CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d
AS '/usr/local/pgsql/lib/liblwgeom', 'BOX2DFLOAT4_in'
LANGUAGE c IMMUTABLE STRICT;
works correctly.
工作正常。
The output of
的输出
% pg_config --pkglibdir
/usr/local/pgsql/lib
appears to be correct.
似乎是正确的。
回答by Johan.l
I struggled with this error as well. I solved it by linking in the PostGIS lib manually to the liblwgeom file, like this:
我也遇到了这个错误。我通过手动将 PostGIS 库链接到 liblwgeom 文件来解决它,如下所示:
ln -s /usr/lib/postgis/1.5.1/postgres/8.4/lib/postgis-1.5.so
/usr/lib/postgresql/8.4/lib/liblwgeom
I have no idea why PostGIS installs itself in the 'wrong' directory, or why PostgreSQL looks for a file named liblwgeom
when it seems to be the same file which PostGIS calls postgis-1.5.so
我不知道为什么 PostGIS 将自己安装在“错误”的目录中,或者为什么 PostgreSQL 寻找一个命名的文件liblwgeom
,它似乎与 PostGIS 调用的文件相同postgis-1.5.so
All I know is that that seems to have fixed my problem.
我所知道的是,这似乎解决了我的问题。
回答by Michael Krelin - hacker
Edited out original reply for it was wrong
编辑了原始回复,因为它是错误的
Now that I've looked up postgresql code I have to admit that this string is supposed to be expanded since 2001 ;-). The expansion is very limited though. It only expands $libdir
followed by directory separator. Still, your output indicates that the string wasn't expanded, because the reported string here is the string actually used for loading library.
现在我已经查找了 postgresql 代码,我不得不承认这个字符串应该从 2001 年开始扩展;-)。但是扩展非常有限。它只扩展$libdir
后跟目录分隔符。尽管如此,您的输出仍表明该字符串未展开,因为此处报告的字符串是实际用于加载库的字符串。
That means that substitution failed. Looking at it closer I can see that the expansion only succeeds if target file actually exists. Assuming your directory separator is /
and DLSUFFIX
is .so
and the file /usr/local/pgsql/lib/liblwgeom.so
actually exists, I have no faintest clue why the hell it fails ;-)
这意味着替换失败。仔细观察,我可以看到只有当目标文件确实存在时,扩展才会成功。假设您的目录分隔符是/
和DLSUFFIX
是.so
并且文件/usr/local/pgsql/lib/liblwgeom.so
确实存在,我不知道它为什么会失败;-)