Is a backend id or something available for use as a foreign key?

Is a backend id or something available for use as a foreign key?

am 24.07.2004 14:35:07 von twanger

Hi,

I have this application which has various users. I want the results of
functions to depend on which user is currently logged on. The usual
reply to this is to use CURRENT_USER. But in my case the application's
users are separate from the database users; the application always uses
the same user to connect to the database. Is there a backend id
available or something similar that would allow me to define a view like
this:

CREATE VIEW my_user_name AS
SELECT
u.user_name as user_name
FROM
users u
JOIN user_has_backend ub ON (u.user_id = ub.user_id)
WHERE
ub.backend_id = CURRENT_BACKEND_ID;


Thanks

--
Markus Bertheau


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Is a backend id or something available for use as a foreign key?

am 24.07.2004 16:39:48 von tgl

Markus Bertheau writes:
> Is there a backend id available or something similar that would allow
> me to define a view like this:

IIRC there is a function to get your backend's PID. It was meant for
identifying rows relevant to you in the pg_stat views, so look in that
part of the documentation.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings