|
132 | 132 | </para>
|
133 | 133 |
|
134 | 134 | <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. |
140 | 144 | </para>
|
141 | 145 |
|
142 | 146 | <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 |
158 | 148 | <command>UPDATE</command> triggers are executed when <literal>ON
|
159 | 149 | CONFLICT DO UPDATE</literal> is specified, regardless of whether or not
|
160 | 150 | any rows were affected by the <command>UPDATE</command> (and
|
|
169 | 159 | triggers.
|
170 | 160 | </para>
|
171 | 161 |
|
| 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 | + |
172 | 170 | <para>
|
173 | 171 | If an <command>UPDATE</command> on a partitioned table causes a row to move
|
174 | 172 | to another partition, it will be performed as a <command>DELETE</command>
|
|
0 commit comments