From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Ruwan Fernando <rutechs(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: How do CHECK Constraint Function privileges work? |
Date: | 2020-04-05 15:42:15 |
Message-ID: | 11652.1586101335@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Sun, Apr 5, 2020 at 1:22 AM Ruwan Fernando <rutechs(at)gmail(dot)com> wrote:
>> My expectation was the INSERT would give me an exception due to
>> "grant_test_role" not having permissions on the "app_private" schema, but
>> it does not. Why does the CHECK constraint function executes fine in this
>> instance?
> While I cannot locate the relevant documentation right now, privileges for
> triggers and constraints attached to a table are made against the owner of
> the table, not the user performing the action.
No, that's not how it works, at least not for CHECK constraints --- those
are executed and privilege-checked as the user running the DML command.
(This might be the wrong thing, but that's what happens.)
The important point about the OP's example is that privilege checks on
schemas only happen at parse time, ie they are interpreted as "can you
look up this object right now?". The only check made at execution time
is whether the calling user has EXECUTE privilege on the function,
working from the already-stored function OID --- so the schema is
irrelevant at that point. Any stored expression such as a view or
CHECK constraint will act that way.
Not sure if this comports with what the SQL spec says, but that's
how PG does it.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Ruwan Fernando | 2020-04-05 15:46:41 | Re: How do CHECK Constraint Function privileges work? |
Previous Message | David G. Johnston | 2020-04-05 14:37:26 | Re: How do CHECK Constraint Function privileges work? |