How to access large objects in Postgresql c-language functions?
I'm writing a c-language user defined function for postgresql 9.3.5. I
didn't use pl/pgsql or pl/python because part of it needs to be written in
C for speed.
The function gets an existing OID as an argument. How can I access & modify
the OID data from within the c-language function? I can't find any docs for
that!
Thanks,
-Spiros
Hi
you can use a lo_* (lo_open, lo_close, ...) functions called via
FirectFunctionCall
http://michael.otacoo.com/postgresql-2/playing-with-large-objects-in-postgres/
http://www.postgresql.org/docs/9.3/static/lo-interfaces.html
Regards
Pavel Stehule
2015-01-26 20:19 GMT+01:00 Spiros Ioannou <sivann@inaccess.com>:
Show quoted text
I'm writing a c-language user defined function for postgresql 9.3.5. I
didn't use pl/pgsql or pl/python because part of it needs to be written in
C for speed.The function gets an existing OID as an argument. How can I access &
modify the OID data from within the c-language function? I can't find any
docs for that!Thanks,
-Spiros
But these need a connection to the postgresql backend. It seems an overkill
for postgresql to connect to itself, I would prefer something more optimal.
It seems for now that reading libpq's source code is the only way to go.
Regards,
Spiros
On 1/26/2015 11:54 AM, Spiros Ioannou wrote:
But these need a connection to the postgresql backend. It seems an
overkill for postgresql to connect to itself, I would prefer something
more optimal. It seems for now that reading libpq's source code is the
only way to go.
you use the SPI functions to execute queries from within a C function.
http://www.postgresql.org/docs/current/static/spi.html
--
john r pierce 37N 122W
somewhere on the middle of the left coast
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
2015-01-26 20:54 GMT+01:00 Spiros Ioannou <sivann@inaccess.com>:
But these need a connection to the postgresql backend. It seems an
overkill for postgresql to connect to itself, I would prefer something more
optimal. It seems for now that reading libpq's source code is the only way
to go.
No, it doesn't need - you can call these functions via DirectFunctionCall
interface
you can look to contrib/lo module for example
Regards
Pavel
Show quoted text
Regards,
Spiros