Re: Cannot reference system table - Mailing list pgsql-admin

From Tom Lane
Subject Re: Cannot reference system table
Date
Msg-id 15118.1035260961@sss.pgh.pa.us
Whole thread Raw
In response to Cannot reference system table  (Casey Allen Shobe <cshobe@secureworks.net>)
List pgsql-admin
Casey Allen Shobe <cshobe@secureworks.net> writes:
> create table    "schemes" (
> ...
>     "user_id"    integer        not null references "pg_user" ("usesysid"),
> ...
> ERROR:  Referenced relation "pg_user" is not a table

> As you can hopefully see, I need to reference the postgres user table
> for data integrity.  Can this be done?

Nope :-(.  The immediate cause of that complaint is that pg_user isn't
a table; it's only a view on pg_shadow.  But even if you'd referenced
pg_shadow, the command would have been rejected.  The difficulty is that
foreign-key constraints require triggers, and we don't support
user-defined triggers on system catalogs.  (That would imply the ability
to run arbitrary user-defined code during system catalog updates, which
has a ton of problems that I won't enumerate here.)

            regards, tom lane

pgsql-admin by date:

Previous
From: Casey Allen Shobe
Date:
Subject: Cannot reference system table
Next
From: "Stein, Jochen"
Date:
Subject: Newbie question about pg_xlog