| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Event trigger table rewrite doc missing ALTER MATERIALIZED VIEW case |
| Date: | 2026-10-27 01:13:36 |
| Message-ID: | 6115F7EE-47F5-4ACD-AF56-5E7C8849503C@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Oct 26, 2026, at 19:39, Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
>
> On Mon, 26 Oct 2026 at 09:29, David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>>
>> On Sunday, October 25, 2026, Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
>>>
>>> Suggested fix:
>>>
>>> diff --git a/doc/src/sgml/event-trigger.sgml b/doc/src/sgml/event-trigger.sgml
>>> --- a/doc/src/sgml/event-trigger.sgml
>>> +++ b/doc/src/sgml/event-trigger.sgml
>>> @@ -150,7 +150,8 @@
>>> <para>
>>> The <literal>table_rewrite</literal> event occurs just before a table is
>>> - rewritten by some actions of the commands <literal>ALTER TABLE</literal>
>>> - and <literal>ALTER TYPE</literal>. While other
>>> + rewritten by some actions of the commands <literal>ALTER TABLE</literal>,
>>> + <literal>ALTER MATERIALIZED VIEW</literal> and <literal>ALTER
>>> TYPE</literal>.
>>> + While other
>>>
>
>
> Hi, thats for looking.
>
>> Probably should also edit: …just before a table [or materialized view] is rewritten…
>>
>> This seems like it should be back-patched thru v15.
>>
>> I’d be a bit more wordy here to connect the unexpected alter type action to typed tables explicitly.
>
> Did that, PFA my version of wording. Applicable from master down to v18.
>
>> David J.
>>
>
>
> --
> Best regards,
> Kirill Reshke
> <v2-master-18-19-table-rewrite.diff>
While verifying the behaviors that this patch describes, I noticed an existing test case:
```
-- matview rewrite when changing access method
CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1 AS a;
ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2;
NOTICE: Table 'heapmv' is being rewritten (reason = 8)
```
The NOTICE is generated by a test function:
```
-- test with more than one reason to rewrite a single table
CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger
LANGUAGE plpgsql AS $$
BEGIN
RAISE NOTICE 'Table ''%'' is being rewritten (reason = %)',
pg_event_trigger_table_rewrite_oid()::regclass,
pg_event_trigger_table_rewrite_reason();
END;
$$;
```
As you have replaced “table” with “relation” in the doc, maybe also update this NOTICE message?
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ZizhuanLiu X-MAN | 2026-10-27 01:47:04 | Re: Fix var_eq_const: sum selectivity of all matching MCV entries instead of stopping at first match |
| Previous Message | Prashant Chinnam | 2026-10-27 01:13:19 | Re: [PATCH] pgcrypto: Fix sha-crypt rounds= values that do not fit in int (BUG #19743) |