how to get the connected session pointer ( Archive * AH)

Started by AI Rummanover 12 years ago5 messagesgeneral
Jump to latest
#1AI Rumman
rummandba@gmail.com

Hi,

Is there a way in Postgresql C function to get the connected session
pointer ( Archive * AH)
and use it for further execution?

Thanks.

#2Luca Ferrari
fluca1978@infinito.it
In reply to: AI Rumman (#1)
Re: how to get the connected session pointer ( Archive * AH)

On Tue, Oct 22, 2013 at 1:32 AM, AI Rumman <rummandba@gmail.com> wrote:

Hi,

Is there a way in Postgresql C function to get the connected session pointer
( Archive * AH)
and use it for further execution?

If I read pg_archiver.c correctly, the AH pointer is used only during
the archiving and is not "globally" stored anywhere, and therefore I
suspect the answer is NO (at least unless you modify the archiver).
What is the aim of having such pointer?

Luca

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3AI Rumman
rummandba@gmail.com
In reply to: Luca Ferrari (#2)
Re: how to get the connected session pointer ( Archive * AH)

I have a libpq C interface code which takes user/password to connect to the
db. Now, I want to call it from a pgsql function where user will not need
to put any user name or password, rather it will use the current session ID.
How can I do it? Any idea, please.

Thanks.

On Tue, Oct 22, 2013 at 2:05 AM, Luca Ferrari <fluca1978@infinito.it> wrote:

Show quoted text

On Tue, Oct 22, 2013 at 1:32 AM, AI Rumman <rummandba@gmail.com> wrote:

Hi,

Is there a way in Postgresql C function to get the connected session

pointer

( Archive * AH)
and use it for further execution?

If I read pg_archiver.c correctly, the AH pointer is used only during
the archiving and is not "globally" stored anywhere, and therefore I
suspect the answer is NO (at least unless you modify the archiver).
What is the aim of having such pointer?

Luca

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: AI Rumman (#3)
Re: how to get the connected session pointer ( Archive * AH)

AI Rumman <rummandba@gmail.com> writes:

I have a libpq C interface code which takes user/password to connect to the
db. Now, I want to call it from a pgsql function where user will not need
to put any user name or password, rather it will use the current session ID.
How can I do it? Any idea, please.

It sounds to me like you're trying to reinvent the foreign-data-wrapper
user identity functionality, and not very well at that.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5John R Pierce
pierce@hogranch.com
In reply to: AI Rumman (#3)
Re: how to get the connected session pointer ( Archive * AH)

On 10/22/2013 9:27 AM, AI Rumman wrote:

I have a libpq C interface code which takes user/password to connect
to the db. Now, I want to call it from a pgsql function where user
will not need to put any user name or password, rather it will use the
current session ID.
How can I do it? Any idea, please.

you shouldn't be calling libpq from within a postgres C function at all.

if you want to make queries on the same database, use the SPI interface,
see http://www.postgresql.org/docs/current/static/spi.html

If you want to connect to another database, use postgres_fdw

--
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