views:

501

answers:

2

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.

A: 

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 ;-)

Michael Krelin - hacker
Why do you say that? This appears to be completely standard usage.
Joe Germuska
Joe, your question took me by surprise, I've changed the answer ;-)
Michael Krelin - hacker
A: 

This should work. Perhaps you are mixing different installations?

Peter Eisentraut