pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is a backend id or something available for use as a foreign key?
2+ messages / 2 participants
[nested] [flat]

* Is a backend id or something available for use as a foreign key?
@ 2004-07-24 12:35 Markus Bertheau <twanger@bluetwanger.de>
  2004-07-24 14:39 ` Re: Is a backend id or something available for use as a foreign key? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Markus Bertheau @ 2004-07-24 12:35 UTC (permalink / raw)
  To: pgsql-sql

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 <twanger@bluetwanger.de>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Is a backend id or something available for use as a foreign key?
  2004-07-24 12:35 Is a backend id or something available for use as a foreign key? Markus Bertheau <twanger@bluetwanger.de>
@ 2004-07-24 14:39 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2004-07-24 14:39 UTC (permalink / raw)
  To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql

Markus Bertheau <twanger@bluetwanger.de> 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-07-24 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-24 12:35 Is a backend id or something available for use as a foreign key? Markus Bertheau <twanger@bluetwanger.de>
2004-07-24 14:39 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox