PostgreSQL 上 $libdir 的问题
简而言之,我的问题是“为什么 $libdir 在我的 PSQL 安装上不起作用”。
CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d
AS '$libdir/liblwgeom', 'BOX2DFLOAT4_in'
LANGUAGE c IMMUTABLE STRICT;
会产生错误
could not access file "$libdir/liblwgeom": No such file or directory
时
CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d
AS '/usr/local/pgsql/lib/liblwgeom', 'BOX2DFLOAT4_in'
LANGUAGE c IMMUTABLE STRICT;
正常工作
。的输出
% pg_config --pkglibdir
/usr/local/pgsql/lib
似乎是正确的。
In short, my question is "why doesn't $libdir work on my PSQL installation."
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也为这个错误而苦苦挣扎。我通过在 PostGIS lib 中手动链接到 liblwgeom 文件解决了这个问题,如下所示:
我不知道为什么 PostGIS 将自身安装在“错误”目录中,也不知道为什么 PostgreSQL 会在以下情况下查找名为
liblwgeom
的文件:它似乎与 PostGIS 调用的文件相同postgis-1.5.so
我所知道的是,这似乎已经解决了我的问题。
I struggled with this error as well. I solved it by linking in the PostGIS lib manually to the liblwgeom file, like this:
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 callspostgis-1.5.so
All I know is that that seems to have fixed my problem.
编辑掉原来的回复,因为它是错误的
现在我已经查找了 postgresql 代码,我不得不承认这个字符串应该从 2001 年开始扩展;-)。但扩展非常有限。它仅扩展
$libdir
后跟目录分隔符。尽管如此,您的输出表明该字符串未扩展,因为此处报告的字符串是实际用于加载库的字符串。这意味着替换失败。仔细观察,我可以发现只有目标文件确实存在时扩展才会成功。假设您的目录分隔符是
/
且DLSUFFIX
是.so
并且文件/usr/local/pgsql/lib/liblwgeom.so
实际上存在,我不知道为什么它会失败;-)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.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
/
andDLSUFFIX
is.so
and the file/usr/local/pgsql/lib/liblwgeom.so
actually exists, I have no faintest clue why the hell it fails ;-)