Re: Pgxs - How to reference another extension - Mailing list pgsql-general

From Joe Conway
Subject Re: Pgxs - How to reference another extension
Date
Msg-id 9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com
Whole thread Raw
In response to Re: Pgxs - How to reference another extension  (Michał Kłeczek <michal@kleczek.org>)
List pgsql-general
On 3/11/24 09:48, Michał Kłeczek wrote:
> 
> 
>> On 11 Mar 2024, at 14:08, Artur Zakirov <zaartur@gmail.com> wrote:
>>
>> On Mon, 11 Mar 2024 at 13:26, Michał Kłeczek <michal@kleczek.org 
>> <mailto:michal@kleczek.org>> wrote:
>>>
>>>
>>>> On 11 Mar 2024, at 11:41, Michał Kłeczek <michal@kleczek.org> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am trying to create an extension that delegates some calls to 
>>>> btree_gist functions:
>>>>
>>>> DirectFunctionCall5Coll(
>>>>               gbt_text_consistent, …other arguments);
>>>>
>>>> Basic PGXS Makefile does not work - I get linker error:
>>>>
>>>> Undefined symbols for architecture arm64:
>>>> "_gbt_text_consistent", referenced from:
>>>>
>>>>
>>>> Anyone could provide me with some hints?
>>>
>>> I’ve added:
>>> PG_LDFLAGS += -L$(shell $(PG_CONFIG) --pkglibdir) -lbtree_gist
>>
>> You can try FunctionCall5Coll() or OidFunctionCall5Coll() functions.
>>
>> OidFunctionCall5Coll() calls fmgr_info() and FunctionCall5Coll(). What
>> you only need is Oid of the target function.
> 
> What I am trying to do is wrapping and decoration of gbt_text_consistent 
> function.
> The reason I want to use DirectFunctionCall5Col is that other variants 
> require catalog lookup
> as I don’t have old of the wrapped function.
> The lookup itself is problematic as the only piece of information I have 
> is the strategy number.
> What’s more - the result of the lookup should be cached in fn_extra and 
> that makes things even more complex.
> 
> Is there any way to simply link against another extension library?


I used this successfully in the past with postgis:

postgis_libdir := $(shell pg_config --pkglibdir)
postgis_libver := $(shell ls -1 $(postgis_libdir) | grep "^postgis")
SHLIB_LINK += -L$(postgis_libdir) -l:$(postgis_libver) -llwgeom

HTH,

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com




pgsql-general by date:

Previous
From: Michał Kłeczek
Date:
Subject: Re: Pgxs - How to reference another extension
Next
From: Pavel Stehule
Date:
Subject: Re: Pgxs - How to reference another extension