Using hstore, json, lo, etc from C extensions? - Mailing list pgsql-general

From Craig Ringer
Subject Using hstore, json, lo, etc from C extensions?
Date
Msg-id 509C9D42.8090003@2ndQuadrant.com
Whole thread Raw
Responses Re: Using hstore, json, lo, etc from C extensions?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi all

With the growing number of extensions that expose useful and increasingly widely used custom data types, I'm wondering: is there any way to use them from a C extension without going through the SPI?

A look at the sources for hstore and json shows that they mostly define static functions and don't present much of an external C API. But say they did; if I or someone else wrote a proper C level API for use of hstore from other C extensions. Is there any way to actually link to it and use it from another C extension?

It looks like extensions can use `requires` to express dependencies on each other ( http://www.postgresql.org/docs/current/static/extend-extensions.html) ... but is there any way to express a *linkage* dependency for C-level use, to actually link to hstore and use its non-static functions?

As far as I can tell the only way to do it at the moment would be to extract most of the guts from the `hstore` extension into a `libhstore` that both the hstore extension and other extensions could link to. There doesn't seem to be provision for doing that in the extension building infrastructure, so it seems it'd be a manual hackjob.

I realise you can still use other extensions via the SPI, I'm just wondering about direct C level usage for performance critical or specialized tasks. With the growing popularity of hstore, the interest in json, etc, this is likely to start coming up more.

Question originally prompted by this SO post: http://stackoverflow.com/questions/13302682/postgresql-udf-in-c-using-hstore

--
Craig Ringer

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Does PostgreSQL have complete functional test cases?
Next
From: Craig Ringer
Date:
Subject: Re: Running out of memory while making a join