Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 93f2349

Browse files
committed
Allow event trigger table_rewrite for ALTER MATERIALIZED VIEW
This event can happen when using SET ACCESS METHOD, as the data files of the materialized need a full refresh but this command tag was not updated to reflect that. The documentation is updated to track this behavior. Author: Onder Kalaci Discussion: https://postgr.es/m/CACawEhXwHN3X34FiwoYG8vXR-oyUdrp7qcfRWSzS+NPahS5gSw@mail.gmail.com Backpatch-through: 15
1 parent c52ad9c commit 93f2349

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

doc/src/sgml/event-trigger.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
<entry align="center"><literal>X</literal></entry>
243243
<entry align="center"><literal>X</literal></entry>
244244
<entry align="center"><literal>-</literal></entry>
245-
<entry align="center"><literal>-</literal></entry>
245+
<entry align="center"><literal>X</literal></entry>
246246
<entry align="left"></entry>
247247
</row>
248248
<row>

src/include/tcop/cmdtaglist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PG_CMDTAG(CMDTAG_ALTER_FUNCTION, "ALTER FUNCTION", true, false, false)
4242
PG_CMDTAG(CMDTAG_ALTER_INDEX, "ALTER INDEX", true, false, false)
4343
PG_CMDTAG(CMDTAG_ALTER_LANGUAGE, "ALTER LANGUAGE", true, false, false)
4444
PG_CMDTAG(CMDTAG_ALTER_LARGE_OBJECT, "ALTER LARGE OBJECT", true, false, false)
45-
PG_CMDTAG(CMDTAG_ALTER_MATERIALIZED_VIEW, "ALTER MATERIALIZED VIEW", true, false, false)
45+
PG_CMDTAG(CMDTAG_ALTER_MATERIALIZED_VIEW, "ALTER MATERIALIZED VIEW", true, true, false)
4646
PG_CMDTAG(CMDTAG_ALTER_OPERATOR, "ALTER OPERATOR", true, false, false)
4747
PG_CMDTAG(CMDTAG_ALTER_OPERATOR_CLASS, "ALTER OPERATOR CLASS", true, false, false)
4848
PG_CMDTAG(CMDTAG_ALTER_OPERATOR_FAMILY, "ALTER OPERATOR FAMILY", true, false, false)

src/test/regress/expected/event_trigger.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ alter table rewriteme
516516
add column another int default -1,
517517
alter column foo type numeric(10,4);
518518
NOTICE: Table 'rewriteme' is being rewritten (reason = 4)
519+
-- matview rewrite when changing access method
520+
CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1 AS a;
521+
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2;
522+
NOTICE: Table 'heapmv' is being rewritten (reason = 8)
523+
DROP MATERIALIZED VIEW heapmv;
519524
-- shouldn't trigger a table_rewrite event
520525
alter table rewriteme alter column foo type numeric(12,4);
521526
begin;

src/test/regress/sql/event_trigger.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ alter table rewriteme
379379
add column another int default -1,
380380
alter column foo type numeric(10,4);
381381

382+
-- matview rewrite when changing access method
383+
CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1 AS a;
384+
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2;
385+
DROP MATERIALIZED VIEW heapmv;
386+
382387
-- shouldn't trigger a table_rewrite event
383388
alter table rewriteme alter column foo type numeric(12,4);
384389
begin;

0 commit comments

Comments
 (0)