Re: Supporting MERGE on updatable views

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: vignesh C <vignesh21@gmail.com>, jian he <jian.universality@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-01-30T11:58:21Z
Lists: pgsql-hackers
On 2024-Jan-29, Dean Rasheed wrote:

> Yeah, for all practical purposes, that check in CheckValidResultRel()
> has been dead code since d751ba5235, but I think it's still worth
> doing, and if we're going to do it, we should do it properly. I don't
> like using elog() in some cases and ereport() in others, but I also
> don't like having that much duplicated code between this and the
> rewriter (and this patch doubles the size of that block).
> 
> A neater solution is to export the rewriter functions and use them in
> CheckValidResultRel(). All these checks can then be reduced to
> 
>     if (!view_has_instead_trigger(...))
>         error_view_not_updatable(...)
> 
> which eliminates a lot of duplicated code and means that we now have
> just one place that throws these errors.

This looks quite nice, thanks.  LGTM.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"No me acuerdo, pero no es cierto.  No es cierto, y si fuera cierto,
 no me acuerdo."                 (Augusto Pinochet a una corte de justicia)



Commits

  1. Support MERGE into updatable views.

  2. Remove field UpdateContext->updated in nodeModifyTable.c

  3. Remove dummy_spinlock