Re: Pgxs - How to reference another extension

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Michał Kłeczek <michal(at)kleczek(dot)org>
Cc: Artur Zakirov <zaartur(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Pgxs - How to reference another extension
Date: 2024-03-11 14:00:15
Message-ID: CAFj8pRDE0FHGPXAszy5RWT7AqX2etz6vsHsD0X7T7NBYfrXq5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

po 11. 3. 2024 v 14:48 odesílatel Michał Kłeczek <michal(at)kleczek(dot)org>
napsal:

>
>
> On 11 Mar 2024, at 14:08, Artur Zakirov <zaartur(at)gmail(dot)com> wrote:
>
> On Mon, 11 Mar 2024 at 13:26, Michał Kłeczek <michal(at)kleczek(dot)org> wrote:
>
>
>
> On 11 Mar 2024, at 11:41, Michał Kłeczek <michal(at)kleczek(dot)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?
>

The advantage of OidFunctionCall is fact, it is working on MacOS. My
extension plpgsql_check has a lot of dependencies on plpgsql.

The linking on MacOS required special section in Makefile

ifeq ($(PORTNAME), darwin)
override CFLAGS += -undefined dynamic_lookup
endif

And there was another problem with loading dependencies. So now, I use only
indirect methods.

DirectFunctionCall is ok just for buildin functions.

Regards

Pavel

>
> —
> Thanks
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2024-03-11 14:19:21 Re: Create a standby server
Previous Message Joe Conway 2024-03-11 13:52:51 Re: Pgxs - How to reference another extension