pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPgxs - How to reference another extension
7+ messages / 4 participants
[nested] [flat]
* Pgxs - How to reference another extension
@ 2024-03-11 10:41 Michał Kłeczek <michal@kleczek.org>
0 siblings, 1 reply; 7+ messages in thread
From: Michał Kłeczek @ 2024-03-11 10:41 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
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?
—
Michal
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Pgxs - How to reference another extension
@ 2024-03-11 12:26 Michał Kłeczek <michal@kleczek.org>
parent: Michał Kłeczek <michal@kleczek.org>
0 siblings, 1 reply; 7+ messages in thread
From: Michał Kłeczek @ 2024-03-11 12:26 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
> 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
to Makefile and I get the following:
ld: library 'btree_gist' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Note that I am on Mac and btree_gist.dylib is present in $(pg_config —pkglibdir)
—
Michal
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Pgxs - How to reference another extension
@ 2024-03-11 13:08 Artur Zakirov <zaartur@gmail.com>
parent: Michał Kłeczek <michal@kleczek.org>
0 siblings, 1 reply; 7+ messages in thread
From: Artur Zakirov @ 2024-03-11 13:08 UTC (permalink / raw)
To: Michał Kłeczek <michal@kleczek.org>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
On Mon, 11 Mar 2024 at 13:26, Michał Kłeczek <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.
FunctionCall5Coll() can be useful and used when you have a cache
variable of the function, where you store previously calculated
FmgrInfo.
--
Artur
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Pgxs - How to reference another extension
@ 2024-03-11 13:48 Michał Kłeczek <michal@kleczek.org>
parent: Artur Zakirov <zaartur@gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Michał Kłeczek @ 2024-03-11 13:48 UTC (permalink / raw)
To: Artur Zakirov <zaartur@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
> 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?
—
Thanks
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Pgxs - How to reference another extension
@ 2024-03-11 13:52 Joe Conway <mail@joeconway.com>
parent: Michał Kłeczek <michal@kleczek.org>
1 sibling, 0 replies; 7+ messages in thread
From: Joe Conway @ 2024-03-11 13:52 UTC (permalink / raw)
To: Michał Kłeczek <michal@kleczek.org>; Artur Zakirov <zaartur@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Pgxs - How to reference another extension
@ 2024-03-11 14:00 Pavel Stehule <pavel.stehule@gmail.com>
parent: Michał Kłeczek <michal@kleczek.org>
1 sibling, 1 reply; 7+ messages in thread
From: Pavel Stehule @ 2024-03-11 14:00 UTC (permalink / raw)
To: Michał Kłeczek <michal@kleczek.org>; +Cc: Artur Zakirov <zaartur@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>
Hi
po 11. 3. 2024 v 14:48 odesílatel Michał Kłeczek <michal@kleczek.org>
napsal:
>
>
> 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> 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?
>
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
>
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Pgxs - How to reference another extension
@ 2024-03-11 17:40 Michał Kłeczek <michal@kleczek.org>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 0 replies; 7+ messages in thread
From: Michał Kłeczek @ 2024-03-11 17:40 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Artur Zakirov <zaartur@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>
> On 11 Mar 2024, at 15:00, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
>
> 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
Thanks! That worked (I am on MacOS indeed).
>
> And there was another problem with loading dependencies.
Right - the problem seems to be:
ERROR: could not load library "/opt/homebrew/opt/postgresql@16/lib/postgresql/btree_gist_extra.dylib": dlopen(/opt/homebrew/opt/postgresql@16/lib/postgresql/btree_gist_extra.dylib, 0x000A): symbol not found in flat namespace '_gbt_text_consistent'
That only happens when btree_gist is _already_ loaded earlier.
When btree_gist is not loaded yet and I perform:
CREATE EXTENSION btree_gist_extra CASCADE;
all works fine.
> So now, I use only indirect methods.
I would like to avoid it but maybe it is going to be necessary.
BTW - the extension is https://github.com/mkleczek/btree_gist_extra
Thanks!
—
Michal
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2024-03-11 17:40 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-11 10:41 Pgxs - How to reference another extension Michał Kłeczek <michal@kleczek.org>
2024-03-11 12:26 ` Michał Kłeczek <michal@kleczek.org>
2024-03-11 13:08 ` Artur Zakirov <zaartur@gmail.com>
2024-03-11 13:48 ` Michał Kłeczek <michal@kleczek.org>
2024-03-11 13:52 ` Joe Conway <mail@joeconway.com>
2024-03-11 14:00 ` Pavel Stehule <pavel.stehule@gmail.com>
2024-03-11 17:40 ` Michał Kłeczek <michal@kleczek.org>
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