pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make rewriter prevent auto-updates on views with conditional INS
Date: Tue, 14 Jan 2020 09:58:06 +0000
Message-ID: <E1irIxa-00072T-Ex@gemulon.postgresql.org> (raw)

Make rewriter prevent auto-updates on views with conditional INSTEAD rules.

A view with conditional INSTEAD rules and no unconditional INSTEAD
rules or INSTEAD OF triggers is not auto-updatable. Previously we
relied on a check in the executor to catch this, but that's
problematic since the planner may fail to properly handle such a query
and thus return a particularly unhelpful error to the user, before
reaching the executor check.

Instead, trap this in the rewriter and report the correct error there.
Doing so also allows us to include more useful error detail than the
executor check can provide. This doesn't change the existing behaviour
of updatable views; it merely ensures that useful error messages are
reported when a view isn't updatable.

Per report from Pengzhou Tang, though not adopting that suggested fix.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAG4reAQn+4xB6xHJqWdtE0ve_WqJkdyCV4P=trYr4Kn8_3_PEA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d751ba523546df2b2709c1ffd4d12d6a25e25bf6

Modified Files
--------------
src/backend/executor/execMain.c               |  8 ++--
src/backend/rewrite/rewriteHandler.c          | 60 ++++++++++++++++++++++++---
src/test/regress/expected/updatable_views.out | 21 ++++++++++
src/test/regress/sql/updatable_views.sql      | 14 +++++++
4 files changed, 94 insertions(+), 9 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1irIxa-00072T-Ex@gemulon.postgresql.org>
Permalink:  ../E1irIxa-00072T-Ex@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1irIxa-00072T-Ex@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Make rewriter prevent auto-updates on views with conditional INS
  In-Reply-To: <E1irIxa-00072T-Ex@gemulon.postgresql.org>
  References: <E1irIxa-00072T-Ex@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox