pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Michał Kłeczek <michal@kleczek.org>
To: Artur Zakirov <zaartur@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Pgxs - How to reference another extension
Date: Mon, 11 Mar 2024 09:52:51 -0400
Message-ID: <9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com> (raw)
In-Reply-To: <66924398-31C4-40CF-B892-CDE266293439@kleczek.org>
References: <C5859291-1CA6-46C6-836B-613200980851@kleczek.org>
	<98BD6A59-DD01-4F6B-8468-8C44B8C81878@kleczek.org>
	<CAKNkYnz7qseGPd+Lh12L6=LsNy8wHaqhPmTiuEeJtGS77VysCw@mail.gmail.com>
	<66924398-31C4-40CF-B892-CDE266293439@kleczek.org>

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






view thread (7+ messages)  latest in thread

Message-ID: <9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com>
Permalink:  ../9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com/
Also on:    postgresql.org/message-id/9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: mail@joeconway.com, michal@kleczek.org, zaartur@gmail.com
  Subject: Re: Pgxs - How to reference another extension
  In-Reply-To: <9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com>
  References: <C5859291-1CA6-46C6-836B-613200980851@kleczek.org> <98BD6A59-DD01-4F6B-8468-8C44B8C81878@kleczek.org> <CAKNkYnz7qseGPd+Lh12L6=LsNy8wHaqhPmTiuEeJtGS77VysCw@mail.gmail.com> <66924398-31C4-40CF-B892-CDE266293439@kleczek.org> <9ce1cb38-fd38-4cd7-bdaf-ac9f910ad4c7@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox