From: | Christoph Moench-Tegeder <cmt(at)burggraben(dot)net> |
---|---|
To: | Avin Kavish <avin(at)baseboard(dot)ai> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Accessing referential constraint information with minimal permissions |
Date: | 2023-06-24 12:56:39 |
Message-ID: | ZJboB4qqIyt9PRPu@elch.exwg.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
## Avin Kavish (avin(at)baseboard(dot)ai):
> I know the information is in `information_schema.referential_constraints`,
> but apparently reading that information requires having write permissions
> to the tables that have references. I don't know why it's designed like
> that.
I guess because "the standard says so".
But then, information_schema.referential_constraints is only a view
and the privilege check is coded into the view, so you could just take
the query from the view and omit the privilege check and Bob is your
uncle.
Another way to approach your problem would be via pg_catalog.pg_constraint
https://www.postgresql.org/docs/current/catalog-pg-constraint.html
and maybe use pg_get_constraintdef() as documented in this table:
https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-INFO-CATALOG-TABLE
Another way to learn about these internals is to use psql with
argument -E (--echo-hidden, or "\set ECHO_HIDDEN on") and watch
psql's queries when displaying objects.
Regards,
Christoph
--
Spare Space
From | Date | Subject | |
---|---|---|---|
Next Message | wen-yi | 2023-06-24 13:36:07 | Re: Why can't lseek the STDIN_FILENO? |
Previous Message | Avin Kavish | 2023-06-24 12:35:45 | Accessing referential constraint information with minimal permissions |