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

From: Markus Bertheau <twanger(at)bluetwanger(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Is a backend id or something available for use as a foreign key?
Date: 2004-07-24 12:35:07
Message-ID: 1090672507.6022.7.camel@teetnang
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)bluetwanger(dot)de>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Garamond 2004-07-24 14:08:21 Re: surrogate key or not?
Previous Message Karsten Hilbert 2004-07-24 09:11:09 Re: surrogate key or not?