Thread: How to access large objects in Postgresql c-language functions?

How to access large objects in Postgresql c-language functions?

From
Spiros Ioannou
Date:
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

Re: How to access large objects in Postgresql c-language functions?

From
Pavel Stehule
Date:
Regards

Pavel Stehule

2015-01-26 20:19 GMT+01:00 Spiros Ioannou <sivann@inaccess.com>:
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

Re: How to access large objects in Postgresql c-language functions?

From
Spiros Ioannou
Date:
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

Re: How to access large objects in Postgresql c-language functions?

From
John R Pierce
Date:
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



Re: How to access large objects in Postgresql c-language functions?

From
Pavel Stehule
Date:


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
 

Regards,

Spiros

Re: How to access large objects in Postgresql c-language functions?

From
Spiros Ioannou
Date:
Thanks, that's interesting, I will look into that.
Regards,
-Spiros