Re: INSERT ... ON CONFLICT UPDATE and RLS

From: David Fetter <david(at)fetter(dot)org>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INSERT ... ON CONFLICT UPDATE and RLS
Date: 2015-01-08 01:16:31
Message-ID: 20150108011631.GA13548@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 07, 2015 at 03:01:20PM -0500, Stephen Frost wrote:
> * Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> > On Wed, Jan 7, 2015 at 4:04 AM, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> > > I think the policies applied should depend on the path taken, so if it
> > > does an INSERT, then only the INSERT CHECK policy should be applied
> > > (after the insert), but if it ends up doing an UPDATE, I would expect
> > > the UPDATE USING policy to be applied (before the update) and the
> > > UPDATE CHECK policy to be applied (after the update). I would not
> > > expect the INSERT CHECK policy to be applied on the UPDATE path.
> >
> > I agree.
>
> I can certainly understand the appeal of this approach, but I don't
> think it makes sense. Consider what happens later on down the road,
> after the code has been written and deployed using INSERT .. ON CONFLICT
> UPDATE where 99% of the time only one path or the other is taken. Then
> the other path is taken and suddenly the exact same command and row ends
> up returning errors. Additional testing should have been done to check
> if that happens, of course, but I really don't like the idea that the
> exact same command, with the exact same policies, would succeed or fail,
> due to policies, based on the data in the database.

There's precedent. Unique constraints, for example.

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-01-08 01:18:58 Re: INSERT ... ON CONFLICT UPDATE and RLS
Previous Message Marko Tiikkaja 2015-01-08 00:24:00 Re: empty select list allowed when using function as table