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

Commit 4b7bba4

Browse files
committed
doc: Add better description for rewrite functions in event triggers
There are two functions that can be used in event triggers to get more details about a rewrite happening on a relation. Both had a limited documentation: - pg_event_trigger_table_rewrite_reason() and pg_event_trigger_table_rewrite_oid() were not mentioned in the main event trigger section in the paragraph dedicated to the event table_rewrite. - pg_event_trigger_table_rewrite_reason() returns an integer which is a bitmap of the reasons why a rewrite happens. There was no explanation about the meaning of these values, forcing the reader to look at the code to find out that these are defined in event_trigger.h. While on it, let's add a comment in event_trigger.h where the AT_REWRITE_* are defined, telling to update the documentation when these values are changed. Backpatch down to 13 as a consequence of 1ad2333, where this area of the documentation has been heavily reworked. Author: Greg Sabino Mullane Discussion: https://postgr.es/m/CAKAnmmL+Z6j-C8dAx1tVrnBmZJu+BSoc68WSg3sR+CVNjBCqbw@mail.gmail.com Backpatch-through: 13
1 parent dda7816 commit 4b7bba4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

doc/src/sgml/event-trigger.sgml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
control statements are available to rewrite a table,
105105
like <literal>CLUSTER</literal> and <literal>VACUUM</literal>,
106106
the <literal>table_rewrite</literal> event is not triggered by them.
107+
To find the OID of the table that was rewritten, use the function
108+
<literal>pg_event_trigger_table_rewrite_oid()</literal> (see
109+
<xref linkend="functions-event-triggers"/>). To discover the reason(s)
110+
for the rewrite, use the function
111+
<literal>pg_event_trigger_table_rewrite_reason()</literal>.
107112
</para>
108113

109114
<para>

doc/src/sgml/func.sgml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31687,8 +31687,12 @@ CREATE EVENT TRIGGER test_event_trigger_for_drops
3168731687
<returnvalue>integer</returnvalue>
3168831688
</para>
3168931689
<para>
31690-
Returns a code explaining the reason(s) for rewriting. The exact
31691-
meaning of the codes is release dependent.
31690+
Returns a code explaining the reason(s) for rewriting. The value is
31691+
a bitmap built from the following values: <literal>1</literal>
31692+
(the table has changed its persistence), <literal>2</literal>
31693+
(default value of a column has changed), <literal>4</literal>
31694+
(a column has a new data type) and <literal>8</literal>
31695+
(the table access method has changed).
3169231696
</para></entry>
3169331697
</row>
3169431698
</tbody>

src/include/commands/event_trigger.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ typedef struct EventTriggerData
3131

3232
extern PGDLLIMPORT bool event_triggers;
3333

34+
/*
35+
* Reasons for relation rewrites.
36+
*
37+
* pg_event_trigger_table_rewrite_reason() uses these values, so make sure to
38+
* update the documentation when changing this list.
39+
*/
3440
#define AT_REWRITE_ALTER_PERSISTENCE 0x01
3541
#define AT_REWRITE_DEFAULT_VAL 0x02
3642
#define AT_REWRITE_COLUMN_REWRITE 0x04

0 commit comments

Comments
 (0)