Re: WITH CHECK and Column-Level Privileges - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: WITH CHECK and Column-Level Privileges
Date
Msg-id 20140926151728.GN16422@tamriel.snowman.net
Whole thread Raw
In response to Re: WITH CHECK and Column-Level Privileges  (Stephen Frost <sfrost@snowman.net>)
Responses Re: WITH CHECK and Column-Level Privileges
List pgsql-hackers
* Stephen Frost (sfrost@snowman.net) wrote:
> > Is there similar problems with unique or exclusion constraints?
>
> That's certainly an excellent question..  I'll have to go look.

Looks like there is an issue here with CHECK constraints and NOT NULL
constraints, yes.  The uniqueness check complains about the key already
existing and returns the key, but I don't think that's actually a
problem- to get that to happen you have to specify the new key and
that's what is returned.

Looks like this goes all the way back to column-level privileges and was
just copied into WithCheckOptions from ExecConstraints. :(

Here's the test case I used:

create table passwd (username text primary key, password text);
grant select (username) on passwd to public;
grant update on passwd to public;
insert into passwd values ('abc','hidden');
insert into passwd values ('def','hidden2');

set role alice;
update passwd set username = 'def';
update passwd set username = null;

Results in:

postgres=> update passwd set username = 'def';
ERROR:  duplicate key value violates unique constraint "passwd_pkey"
DETAIL:  Key (username)=(def) already exists.
postgres=> update passwd set username = null;
ERROR:  null value in column "username" violates not-null constraint
DETAIL:  Failing row contains (null, hidden).

Thoughts?
Thanks,
    Stephen

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: proposal: rounding up time value less than its unit.
Next
From: Stephen Frost
Date:
Subject: Re: WITH CHECK and Column-Level Privileges