Materialized view rewrite is broken when there is an event trigger

From: Önder Kalacı <onderkalaci(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Materialized view rewrite is broken when there is an event trigger
Date: 2022-08-09 12:55:06
Message-ID: CACawEhXwHN3X34FiwoYG8vXR-oyUdrp7qcfRWSzS+NPahS5gSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Attached a patch to fix as well. If the patch looks good to you, can you
consider getting this to PG 15?

Steps to repro:
-- some basic examples from src/test/regress/sql/create_am.sql
CREATE TABLE heaptable USING heap AS
SELECT a, repeat(a::text, 100) FROM generate_series(1,9) AS a;
CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler;
CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT * FROM heaptable;

-- altering MATERIALIZED
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2;
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap;

-- setup event trigger
CREATE OR REPLACE FUNCTION empty_event_trigger()
RETURNS event_trigger AS $$
DECLARE
BEGIN
END;
$$ LANGUAGE plpgsql;
CREATE EVENT TRIGGER empty_triggger ON sql_drop EXECUTE PROCEDURE
empty_event_trigger();

-- now, after creating an event trigger, ALTER MATERIALIZED VIEW fails
unexpectedly
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2;
ERROR: unexpected command tag "ALTER MATERIALIZED VIEW"

Thanks,
Onder Kalaci

Attachment Content-Type Size
v1-Allow-MATERIALIZED-VIEW-Rewrite-when-event-triggers.patch application/octet-stream 3.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-08-09 13:13:21 Re: Materialized view rewrite is broken when there is an event trigger
Previous Message David Rowley 2022-08-09 12:53:04 Re: Reducing the chunk header sizes on all memory context types