| From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> | 
|---|---|
| To: | C G <csgcsg39(at)hotmail(dot)com> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Foreign keys and pg_user table | 
| Date: | 2003-12-11 17:25:02 | 
| Message-ID: | 20031211092114.T34888@megazone.bigpanda.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Thu, 11 Dec 2003, C G wrote:
> I'm trying to create a table where the username and email can only be
> inserted into the table if the username is already in pg_user. The method
> I'm trying is:
>
> CREATE user(
>   usename name,
>   email text,
>   FOREIGN KEY usename REFERENCES (pg_user)
> );
>
> but I get told that "...pg_user is not a table."
Which is true, it's a view.  However, even were it a table,
it's a system table and references to them are not allowed (in recent
versions it'll fail to make the constraint, in older versions it would
make the constraint but it wouldn't work).
> Is there another way of doing what I want?
You could potentially do the insert/update on user time check in a custom
trigger.  That wouldn't prevent you from dropping a user later that was
referenced, however.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Netto | 2003-12-11 17:35:39 | Is it not datestyle that determines date format output? | 
| Previous Message | Oliver Elphick | 2003-12-11 17:21:28 | Re: Strange permission problem regarding pg_settings |