PostgreSQL 上 $libdir 的问题

发布于 2024-08-03 20:04:07 字数 603 浏览 6 评论 0原文

简而言之,我的问题是“为什么 $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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

宛菡 2024-08-10 20:04:07

我也为这个错误而苦苦挣扎。我通过在 PostGIS lib 中手动链接到 liblwgeom 文件解决了这个问题,如下所示:

ln -s /usr/lib/postgis/1.5.1/postgres/8.4/lib/postgis-1.5.so 
    /usr/lib/postgresql/8.4/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:

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

All I know is that that seems to have fixed my problem.

嘿咻 2024-08-10 20:04:07

编辑掉原来的回复,因为它是错误的

现在我已经查找了 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 / 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 ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文