Re: UPDATE works on a view?

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: UPDATE works on a view?
Date: 2020-08-05 18:44:22
Message-ID: CAOC+FBUs0q+X5zKhrpf1yJ+9iFqM1tj-NLnGrD2CMb_fh==PCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Wild. Dead simple, had no idea, works. Learn something new every day.

Part of me thinks it's better for stuff to be explicit in what it is
updating and views abstract that a little, but it's nice.

Thanks Tom!

On Wed, Aug 5, 2020 at 11:42 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Wells Oliver <wells(dot)oliver(at)gmail(dot)com> writes:
> > Err, sorry if this is back to basics, but I was very confused by someone
> > being able to *UPDATE myview SET col = 1* and the underlying table
> actually
> > being updated properly.
> > Is this recent? When did we become able to UPDATE on views?
>
> Depends on your definition of "recent" ...
>
>
> Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> Branch: master Release: REL9_3_BR [a99c42f29] 2012-12-08 18:26:21 -0500
>
> Support automatically-updatable views.
>
> This patch makes "simple" views automatically updatable, without the
> need
> to create either INSTEAD OF triggers or INSTEAD rules. "Simple" views
> are those classified as updatable according to SQL-92 rules. The
> rewriter
> transforms INSERT/UPDATE/DELETE commands on such views directly into an
> equivalent command on the underlying table, which will generally have
> noticeably better performance than is possible with either triggers or
> user-written rules. A view that has INSTEAD OF triggers or INSTEAD
> rules
> continues to operate the same as before.
>
> For the moment, security_barrier views are not considered simple.
> Also, we do not support WITH CHECK OPTION. These features may be
> added in future.
>
> Dean Rasheed, reviewed by Amit Kapila
>
>
> regards, tom lane
>

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Paul Förster 2020-08-06 05:56:27 Re: UPDATE works on a view?
Previous Message Tom Lane 2020-08-05 18:42:42 Re: UPDATE works on a view?