Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2cc2d02

Browse files
committed
doc: clarify handling of ON CONFLICT with triggers
The previous wording was confusing. Also move partitioning mention to amore logical location.Reported-by: neil@fairwindsoft.comDiscussion:https://postgr.es/m/20170703200710.27956.64565@wrigleys.postgresql.orgBackpatch-through: master
1 parente5b8c4f commit2cc2d02

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

‎doc/src/sgml/trigger.sgml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,19 @@
132132
</para>
133133

134134
<para>
135-
A statement that targets a parent table in an inheritance or partitioning
136-
hierarchy does not cause the statement-level triggers of affected child
137-
tables to be fired; only the parent table's statement-level triggers are
138-
fired. However, row-level triggers of any affected child tables will be
139-
fired.
135+
If an <command>INSERT</command> contains an <literal>ON CONFLICT
136+
DO UPDATE</literal> clause, it is possible for row-level
137+
<literal>BEFORE</literal> <command>INSERT</command> and then
138+
<literal>BEFORE</literal> <command>UPDATE</command> triggers
139+
to be executed on triggered rows. Such interactions can be
140+
complex if the triggers are not idempotent because change made by
141+
<literal>BEFORE</literal> <command>INSERT</command> triggers will be
142+
seen by <literal>BEFORE</literal> <command>UPDATE</command> triggers,
143+
including changes to <varname>EXCLUDED</varname> columns.
140144
</para>
141145

142146
<para>
143-
If an <command>INSERT</command> contains an <literal>ON CONFLICT
144-
DO UPDATE</literal> clause, it is possible that the effects of
145-
row-level <literal>BEFORE</literal> <command>INSERT</command> triggers and
146-
row-level <literal>BEFORE</literal> <command>UPDATE</command> triggers can
147-
both be applied in a way that is apparent from the final state of
148-
the updated row, if an <varname>EXCLUDED</varname> column is referenced.
149-
There need not be an <varname>EXCLUDED</varname> column reference for
150-
both sets of row-level <literal>BEFORE</literal> triggers to execute,
151-
though. The
152-
possibility of surprising outcomes should be considered when there
153-
are both <literal>BEFORE</literal> <command>INSERT</command> and
154-
<literal>BEFORE</literal> <command>UPDATE</command> row-level triggers
155-
that change a row being inserted/updated (this can be
156-
problematic even if the modifications are more or less equivalent, if
157-
they're not also idempotent). Note that statement-level
147+
Note that statement-level
158148
<command>UPDATE</command> triggers are executed when <literal>ON
159149
CONFLICT DO UPDATE</literal> is specified, regardless of whether or not
160150
any rows were affected by the <command>UPDATE</command> (and
@@ -169,6 +159,14 @@
169159
triggers.
170160
</para>
171161

162+
<para>
163+
A statement that targets a parent table in an inheritance or partitioning
164+
hierarchy does not cause the statement-level triggers of affected child
165+
tables to be fired; only the parent table's statement-level triggers are
166+
fired. However, row-level triggers of any affected child tables will be
167+
fired.
168+
</para>
169+
172170
<para>
173171
If an <command>UPDATE</command> on a partitioned table causes a row to move
174172
to another partition, it will be performed as a <command>DELETE</command>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp