Re: Feature: triggers on materialized views

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Mitar <mmitar(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Feature: triggers on materialized views
Date: 2019-01-04 11:23:28
Message-ID: 7dad77c7-15b4-898d-0461-05fc3cf9d1ca@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28/12/2018 08:43, Mitar wrote:
> A summary of the patch: This patch enables adding AFTER triggers (both
> ROW and STATEMENT) on materialized views. They are fired when doing
> REFRESH MATERIALIZED VIEW CONCURRENTLY for rows which have changed.

What bothers me about this patch is that it subtly changes what a
trigger means. It currently means, say, INSERT was executed on this
table. You are expanding that to mean, a row was inserted into this
table -- somehow.

Triggers should generally refer to user-facing commands. Could you not
make a trigger on REFRESH itself?

> Triggers are not fired if you call REFRESH without CONCURRENTLY. This
> is based on some discussion on the mailing list because implementing
> it for without CONCURRENTLY would require us to add logic for firing
> triggers where there was none before (and is just an efficient heap
> swap).

This is also a problem, because it would allow bypassing the trigger
accidentally.

Moreover, consider that there could be updatable materialized views,
just like there are updatable normal views. And there could be triggers
on those updatable materialized views. Those would look similar but
work quite differently from what you are proposing here.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2019-01-04 11:25:48 commit fest app: Authors
Previous Message Charles Clavadetscher 2019-01-04 10:56:22 RE: Potentially undocumented behaviour change in Postgres 11 concerning OLD record in an after insert trigger